router.get().failureHandler(event -> {
log.warn("Failed to handle route: {}", event.failure().getMessage());
event.reroute("/app/dashboard/");
});
router.route(HttpMethod.GET, "/*").last().handler(event -> event.reroute("/app/dashboard/"));
router.route(HttpMethod.GET, "/*").last().handler(event -> event.response().putHeader("location", "/app/dashboard/").setStatusCode(302).end());
Thanks, Thomas,What I need to accomplish is any URL that is not matched by the router will be redirected to dashboard.Did you mean this? is it guaranteed to be matched last? as I mentioned I have other routes that are added dynamically so very likely to be added after this route is defined.router.route(HttpMethod.GET, "/*").last().handler(event -> event.response().putHeader("location", "/app/dashboard/").setStatusCode(302).end());
On Monday, June 3, 2019 at 9:32:10 AM UTC+1, Thomas SEGISMONT wrote:If you get stack overflow perhaps something wrong happens while rerouting and the request is rerouted to the dashboard again.I don't know the business context but I instead of redirecting internally I would send a 302 response:HTTP/1.1 302 Found
Location: /app/dashboardAnd also, sometimes it's just better to send a 404. If you have static file for examples, and the file is missing, then your reply will always be the dashboard html.
--
You received this message because you are subscribed to the Google Groups "vert.x" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vertx+un...@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/ad567972-9632-4172-be70-6dca6ce439a8%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.