Details
-
Suggestion
-
Resolution: Unresolved
-
Not Evaluated
-
None
-
None
-
None
-
13
-
Foundation PM Prioritized
Description
Currently you have to write something like
QHttpServer server; server.addRoute("/api/something", ...); server.addRoute("/api/somethingelse", ...); server.addRoute("/api/anotherthing", ...);
What would be nice is if the /api/ part could be omitted somehow, a suggestion I have is a new class that would enable something like this:
QHttpServer server; auto api = server.withBasePath("/api"); api.addRoute("/something", ...); api.addRoute("/somethingelse", ...); api.addRoute("/anotherthing", ...);
Not only would this make it look cleaner, if it worked 'recursively' it would also make enabling support for reverse proxying with a base path much easier, and wouldn't need to permeate every single addRoute call, nor would there need to be a global setBasePath that affects the whole server. If your setup previously looked like the snippet above you could just make the change as below:
QHttpServer server; auto base = server.withBasePath("/myservice") auto api = base.withBasePath("/api"); api.addRoute("/something", ...); // => the path for this route is /myservice/api/something ...