How to extend the web server

Hello,
Since it’s a question about the web server, i am not sure that I am at the good place to ask it… Sorry if i’m not…

Some background:
I created a project in which I extended GraphHopper to add my custom weighting as explained there: https://github.com/graphhopper/graphhopper/blob/master/docs/core/weighting.md.

I created another project that extended the class of GraphHopper Web to for the server to use my extended version of GraphHopper.

Also, in my extended version of GraphHopper, I extended GHResponse to have a method returning the time for a routing using my custom weighting.

I would like to return this property in the results of the web server.
However, I would like to keep “extending” and to avoid to modify the source code.

Unfortunately, it seems that the only way to do that is to modify the source code of GraphHopperServlet and of SimpleRouteSerializer.

Am I right? Is there plan for more flexibility to add parameters to a web request?

Thanks a lot!

You can put custom request parameters into the hints of the GHRequest and also results into the hints of the response which will then be serialized as json parameters.

1 Like