Skip to content

Commit

Permalink
fabric8io#275: Just for fun using v2 hawtio console.
Browse files Browse the repository at this point in the history
  • Loading branch information
davsclaus committed May 21, 2015
1 parent 945cd82 commit 56e52f4
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 13 deletions.
4 changes: 2 additions & 2 deletions console/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@
<dependencies>
<dependency>
<groupId>io.hawt</groupId>
<artifactId>hawtio-web</artifactId>
<version>${hawtio.version}</version>
<artifactId>hawtio-war</artifactId>
<version>2.0-SNAPSHOT</version>
<type>war</type>
<exclusions>
<exclusion>
Expand Down
7 changes: 5 additions & 2 deletions jube/src/main/java/io/fabric8/jube/main/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ public static void main(final String[] args) throws Exception {
//context.addServlet(servletHolder, "/kubernetes/api/*");
context.addServlet(WatchWebSocketServlet.class, "/api/*");
//context.addServlet(WatchWebSocketServlet.class, "/kubernetes/api/*");
context.addServlet(new ServletHolder(new RootServlet()), "/");
//context.addServlet(new ServletHolder(new RootServlet()), "/");

handlers.addHandler(context);

Expand Down Expand Up @@ -297,6 +297,9 @@ private static void createWebapp(HandlerCollection handlers, Set<String> foundUR
System.out.println("adding web context path: /" + contextPath + " war: " + filePath);
}
WebAppContext webapp = new WebAppContext();
if ("hawtio".equals(contextPath)) {
contextPath = "";
}
webapp.setContextPath("/" + contextPath);
webapp.setWar("file://" + filePath);
handlers.addHandler(webapp);
Expand All @@ -320,7 +323,7 @@ public static String createContextPath(String uri) {
if (contextPath.startsWith("hawtio-swag")) {
contextPath = "hawtio-swagger";
} else if (contextPath.startsWith("hawtio-") || contextPath.startsWith("console-")) {
contextPath = "hawtio";
contextPath = "/";
}
return contextPath;
}
Expand Down
8 changes: 1 addition & 7 deletions jube/src/main/java/io/fabric8/jube/main/RootServlet.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,16 +21,10 @@
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.eclipse.jetty.util.URIUtil;

public class RootServlet extends HttpServlet {

@Override
protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
// only redirect if its / to hawtio
if (req.getRequestURI().equals("/")) {
String url = URIUtil.addPaths(req.getRequestURI(), "hawtio");
resp.sendRedirect(url);
}
// do not redirect as hawtio v2 console do not support using /hawtio as context-path yet
}
}
3 changes: 1 addition & 2 deletions jube/src/test/java/io/fabric8/jube/main/ContextPathTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,9 @@ public class ContextPathTest {

@Test
public void testContextPath() throws Exception {
assertContextPath("file:/projects/jube/app/target/jube/maven/hawtio-web-1.4.27.war!/WEB-INF/web.xml", "hawtio");
assertContextPath("file:/projects/jube/app/target/jube/maven/hawtio-web-1.4.27.war!/WEB-INF/web.xml", "/");
}


@Test
public void testFilePath() throws Exception {
assertFilePath("file:/projects/jube/app/target/jube/maven/hawtio-web-1.4.27.war!/WEB-INF/web.xml", "/projects/jube/app/target/jube/maven/hawtio-web-1.4.27.war");
Expand Down

0 comments on commit 56e52f4

Please sign in to comment.