Scenario:
- I have placed my static data on webroot/* folder location and server serves those data on request.
- I have lots of routes for routing APIs.
Router's Code:
Router router = Router.router(vertx);
router.route().handler(BodyHandler.create());
router.route("/api/login/account").handler((RoutingContext ctx) -> {
// Handler is here
});
router.route("/api/currentUser").handler(ctx -> {
// Handler is here
});
router.route().handler(StaticHandler.create());
router.route("/*").hanler(StaticHandler.create("webroot/index.html"));
Folder webroot has following files:
- index.css
- index.html
- image/image.jpg
Problem:
- Need to serve webroot/index.html file on routing mismatch (it is not working; returning value **'Resource not found')**: if I request the data for /xyz/abc then webroot/index.html should be served.
- Need to serve other static files as it's requested parameter (it is working): if I request the data for /index.css then webroot/index.css should be served.
- Need to response data for API request (it is working): if I request the data for /api/login/account then it should respond.
Where I missed the here? And what would be the solution?
Aucun commentaire:
Enregistrer un commentaire