Skip to content

catch all

Roland Schuller edited this page Apr 4, 2019 · 1 revision

CatchAll

A CatchAll endpoint says ok to all requests. But it is the last to be asked. So if there is any Path or Endpoint that works for this request it will be taken first.

RestPath html=server.getRootEndpoint().addSubPath(new RestPath("html"));
html.setCatchAllEndPoint(new StaticFileEndpoint(new File("/www/html"), new NoCachePolicy()));
html.addSubPath(new RestPath("js")).setCatchAllEndPoint(new StaticFileEndpoint(new File("/www/js"), new NoCachePolicy()));

If i call http://localhost:3000/html/test.html or http://localhost:3000/html/my/Path/test.html I will be served by the first CatchAll endpoint for html.

But http://localhost:3000/html/js/jquery.js will be served by the second one because the Path 'js' under 'html' will be used bevore the CatchAll in 'html'

Own CatchAll endpoints

Make your own Endpoint extends RestEndpoint or GetEndpoint (for only 'GET' requests)

Override the 'Call' function.

The full path under the last defined RestPath will be available as UrlParameters.

In the case of http://localhost:3000/html/my/Path/test.html

UrlParameter.get("0") = "my"

UrlParameter.get("1") = "Path"

UrlParameter.get("2") = "test.html"

So you decide what to do with this call.

Clone this wiki locally