endpoint routing fix

This commit is contained in:
simon 2020-09-07 09:33:35 +03:00
parent a7633b2031
commit 9112d4a34f

View file

@ -52,13 +52,10 @@ public class OsmAndHttpServer extends NanoHTTPD {
private NanoHTTPD.Response routeApi(NanoHTTPD.IHTTPSession session) { private NanoHTTPD.Response routeApi(NanoHTTPD.IHTTPSession session) {
String uri = session.getUri(); String uri = session.getUri();
int pathEnd = uri.indexOf("/", 1); for (String path : endpoints.keySet()){
if (pathEnd != -1) { if (uri.startsWith(path)) {
uri = uri.substring(0, pathEnd); return endpoints.get(path).process(session);
} }
ApiEndpoint endpoint = endpoints.get(uri);
if (endpoint != null) {
return endpoint.process(session);
} }
return ErrorResponses.response404; return ErrorResponses.response404;
} }