Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[kura-dev] Regarding URL rewriting

Hi!

Out of the box kura seems to support JAX-RS-like endpoint declarations, where you use javax.ws.rs package to declare new endpoints. This works alright as long as requester follows the HTTP standard, which does not permit the url to end in `/` as long as absolute path is not empty (ex. you can't have "/api/users/" as your URL). Requesting such URLs is prohibited by Web Browsers since they just rewrite the URL as "/api/users" by default themselves, but you don't have such liberties when using Web Applications that are hosted not at topmost URL (as in, not at "/"). In turn, frameworks, in my case Angular, treats "/api/users/" as its base URL and forces the browser to reflect that using <base href="" html tag. Thus, if you were to submit a request to "/api/users/" while that Angular application is running, browser does not rewrite "/api/users/" to "/api/users" and submits the request to original URL, causing HttpContextHandler not find the desired Endpoint for that URL and return a 404 page not found error while showing that the request indeed went to "/api/users/".

Hence my question: Is it possible to do URL rewriting and/or do internal redirecting in Kura? If so, how? OSGi specification suggests using http whiteboard and javax.servlet.Filter interface, but those are not invoked if there is no endpoint matching that particular URL.

Cheers.

Back to the top