I'm trying to clarify some concept that confuse me slightly around http4s path.
Quoting the documentation,
Path info
Path matching is done on the request’s pathInfo. Path info is the request’s URI’s path after the following:
- the mount point of the service
- the prefix, if the service is composed with a Router
- the prefix, if the service is rewritten with TranslateUri
Matching on
request.pathInfoinstead ofrequest.uri.pathallows multiple services to be composed without rewriting all the path matchers.
I would like to clarify the notion of mount point and prefix.
- Can some give an example of a mount point definition vs a prefix ?
- Can a service have both a mount point and prefix that are not the same ?
I suspect that the mount point in this example is /hello?
HttpRoutes.of[IO] {
case GET -> Root / "hello" => Ok("hello")
}
- When writing the below code, we are defining 2 prefixes
/and/api, but are they also consider mount point ?
val services = tweetService <+> helloWorldService
val httpApp = Router("/" -> helloWorldService, "/api" -> services).orNotFound
Because quoting the documentation, we have:
We start from a BlazeServerBuilder, and then mount the helloWorldService under the base path of / and the remainder of the services under the base path of /api
- For the second prefix
/api, what is the Root of thehelloWorldServicein
case GET -> Root / "hello"
is it /api, as in Root = /api ?
- What is the mount point of the
helloWorldServicein that circumstance and what is the prefix ?