What is a context path? :sweat_smile:
# server
m
What is a context path? 😅
👍 1
t
it's like setting a new root if your have a service that is supposed to be availabe at
<http://example.com/service/:path|example.com/service/:path>
, you will have to declare all your routes as
/service/...
if you can set a context path, you can build your app as normal without having to take this into account
an example with some code: https://javalin.io/news/2017/10/16/javalin-0.5.3-released.html#context-paths (i made this poll to decide if i should include this feature in javalin)
s
In http4k we call this "nestable routes" https://www.http4k.org/cookbook/nestable_routes/
m
Thanks for the explanation, I remeb r now from long time ago. It's like nesting routes in ktor. Nice to have. But I never liked the big architecture of application servers relying on such paths for distinct applications. It's usually better to use micro services and a dedicated router, isn't it?
s
It depends on your approach to microservices. If a single service provide multiple endpoints (e.g
/v1/x
,
/v1/y
,
/v2/x
) I'd probably prefer managing those on the app itself rather than using a router.
👍 1