[tink_web] How to mount the application under a specific path?

The tink_web documentation assumes that the application will always be mounted at the web root. But how to mount an app under a non-root path?

Let’s say that I have 3 different environments where the app is deployed, each one having its own mount point:

In development, everything is OK. But in other environments, the routing fails because of the mount point.

I didn’t see any API that allow me to specify the mount point. How can I dynamically specify it, or make the router strip the mount point from the requests?

The easiest solution is calling sub on the router context, e.g.:

container.run(function(req) {
  return router.route(Context.ofRequest(req).sub(1))

For fancier things, you can always construct a new IncomingRequest from the existing one to modify whatever you want.


Thanks a lot @back2dos, it works :smiling_face_with_three_hearts:

Note to readers: the number to use as sub() parameter corresponds to the number of folders to strip from the request path (i.e. 0 for the root path, 1 for /api, 2 for /apps/my_app, etc.).