diff --git a/backend/src/main/java/edu/internet2/tier/shibboleth/admin/ui/controller/RootUiViewController.java b/backend/src/main/java/edu/internet2/tier/shibboleth/admin/ui/controller/RootUiViewController.java index 35c06653d..dabb03e55 100644 --- a/backend/src/main/java/edu/internet2/tier/shibboleth/admin/ui/controller/RootUiViewController.java +++ b/backend/src/main/java/edu/internet2/tier/shibboleth/admin/ui/controller/RootUiViewController.java @@ -4,30 +4,34 @@ import org.springframework.beans.factory.annotation.Value; import org.springframework.core.io.Resource; import org.springframework.stereotype.Controller; +import org.springframework.util.StreamUtils; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.ResponseBody; import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; import java.io.IOException; import java.io.OutputStream; +import java.nio.charset.Charset; @Controller public class RootUiViewController { @Value("classpath:/resources/index.html") - Resource resourceFile; + Resource indexHtmlResource; @RequestMapping("/") - @ResponseBody - public void index(HttpServletRequest request, OutputStream os) throws IOException { + //@ResponseBody + public void index(HttpServletRequest request, HttpServletResponse response) throws IOException { + //TODO: Use Jsoup lib to inject context path into DOM before writing to response buffer + final String ctxPath = request.getContextPath(); - try { - byte[] indexHtmlBytes = ByteStreams.toByteArray(resourceFile.getInputStream()); - os.write(indexHtmlBytes, 0, indexHtmlBytes.length); - //os.write(ctxPath.getBytes(), 0, ctxPath.length()); - } - finally { - os.close(); - } + + //This does not work! In order form Angular to kick in we need to redirect to index.html + String indexHtmlAsString = StreamUtils.copyToString(indexHtmlResource.getInputStream(), Charset.defaultCharset()); + //byte[] indexHtmlBytes = ByteStreams.toByteArray(indexHtmlResource.getInputStream()); + response.setHeader("Content-Type", "text/html"); + response.getWriter().print(indexHtmlAsString); + //os.write(ctxPath.getBytes(), 0, ctxPath.length()); } }