public class AdminUIRestVerticle extends RestApiVerticle {
@Override
public void start(Future<Void> future) throws Exception {
super.start();
final Router router = Router.router(vertx);
// Body handler
router.route("/*").handler(StaticHandler.create());
String host = config().getString("address", "0.0.0.0");
int port = config().getInteger("port", 8080);
// create HTTP server and publish REST service
createHttpServer(router, host, port)
.setHandler(future.completer());
}
}
| --snip-- route("/*").method(GET).handler(rh -> { rh.response().sendFile("./demo/dist/index.html"); }); --snap-- |
See https://github.com/gentics/mesh/blob/1e0e81035632494eab737493a8da4c62fc57dd9d/demo/src/main/java/com/gentics/mesh/demo/verticle/DemoAppEndpoint.java#L43 how I use it in my App.
--
You received this message because you are subscribed to a topic in the Google Groups "vert.x" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/vertx/3gm75Yh6rkI/unsubscribe.
To unsubscribe from this group and all its topics, send an email to vertx+unsubscribe@googlegroups.com.
Visit this group at https://groups.google.com/group/vertx.
To view this discussion on the web, visit https://groups.google.com/d/msgid/vertx/94b889a5-20c1-4cc4-995e-0173d57c69ee%40googlegroups.com.
--
You received this message because you are subscribed to a topic in the Google Groups "vert.x" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/vertx/3gm75Yh6rkI/unsubscribe.
To unsubscribe from this group and all its topics, send an email to vertx+unsubscribe@googlegroups.com.
Visit this group at https://groups.google.com/group/vertx.
To view this discussion on the web, visit https://groups.google.com/d/msgid/vertx/163f8467-ade6-4c01-93b1-1098589800bb%40googlegroups.com.
router.route("/*").handler(StaticHandler.create());and
router.route("/*"). handler(this::rediretHandler);
protected void rediretHandler(RoutingContext rc) {
rc.response().putHeader("Location", "/index.html").setStatusCode(302).end();
}
protected void rediretHandler(RoutingContext rc) {
System.out.println("Here: " + rc.currentRoute().getPath());
rc.response().putHeader("Location", rc.currentRoute().getPath()).setStatusCode(302).end();
}
protected void rediretHandler(RoutingContext rc) {
System.out.println("Heressss: " + rc.request().path());
rc.response().putHeader("Location", rc.request().path()).setStatusCode(304).end();
}
--
You received this message because you are subscribed to a topic in the Google Groups "vert.x" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/vertx/3gm75Yh6rkI/unsubscribe.
To unsubscribe from this group and all its topics, send an email to vertx+unsubscribe@googlegroups.com.
Visit this group at https://groups.google.com/group/vertx.
To view this discussion on the web, visit https://groups.google.com/d/msgid/vertx/a1ed1299-6a80-49bd-b0c5-a6c72ef52915%40googlegroups.com.
ok but setting location to / and 302 always erases the route in tne browser.
On Feb 22, 2018 1:58 AM, "Paulo Lopes" <pml...@gmail.com> wrote:
304 is more suited for caching purposes as it states that the resouce has not been modified since the last access. I don't think you should be using that status code...--
On Thursday, February 22, 2018 at 2:46:08 AM UTC+1, javadevmtl wrote:This seems even more desirable as an effect? And it preserves the path on the browser.
protected void rediretHandler(RoutingContext rc) {
System.out.println("Heressss: " + rc.request().path());
rc.response().putHeader("Location", rc.request().path()).setStatusCode(304).end();
}
On Wednesday, 21 February 2018 20:27:00 UTC-5, javadevmtl wrote:This works also...protected void rediretHandler(RoutingContext rc) {
System.out.println("Here: " + rc.currentRoute().getPath());
rc.response().putHeader("Location", rc.currentRoute().getPath()).setStatusCode(302).end();
}And doesn't make extra requests to the servers. Is that the desired effect?
On Wednesday, 21 February 2018 20:18:06 UTC-5, javadevmtl wrote:Yeah the redirect way doesn't work for me so far... I use the send file method and it works. I can browse TODOS, The redirect way always send me back to index.html which renders the main page over and over.
You received this message because you are subscribed to a topic in the Google Groups "vert.x" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/vertx/3gm75Yh6rkI/unsubscribe.
To unsubscribe from this group and all its topics, send an email to vertx+un...@googlegroups.com.
To unsubscribe from this group and all its topics, send an email to vertx+unsubscribe@googlegroups.com.
Visit this group at https://groups.google.com/group/vertx.
To view this discussion on the web, visit https://groups.google.com/d/msgid/vertx/fbd00664-458b-4b5a-b663-c24e9e076cd9%40googlegroups.com.
router.route("/*").handler(StaticHandler.create());
router.route("/*").handler(rc -> {
rc.reroute("index.html");
});