factor in @alp's feedbacks on PR #1455

This commit is contained in:
bChiquet 2021-09-29 19:59:55 +02:00
parent 29aa10176d
commit 8b93af3d12

View file

@ -390,10 +390,10 @@ with the rest of your API. But you can plug in everything that is an
`Application`, e.g. a whole web application written in any of the web `Application`, e.g. a whole web application written in any of the web
frameworks that support `wai`. frameworks that support `wai`.
Be mindful! This library works by pattern-matching the different routes that are Be mindful! The `servant-server`'s router works by pattern-matching the
composed using `:<|>`. `Raw`, as an escape hatch, matches any route that hasn't different routes that are composed using `:<|>`. `Raw`, as an escape hatch,
been matched by previous patterns. Therefore, any subsequent route will be silently matches any route that hasn't been matched by previous patterns. Therefore,
ignored. any subsequent route will be silently ignored.
``` haskell ``` haskell
type UserAPI14 = Raw type UserAPI14 = Raw
@ -403,12 +403,12 @@ type UserAPI14 = Raw
-- endpoint matches requests before -- endpoint matches requests before
``` ```
A simple way to avoid this pitfall is to either use `Raw` as the last A simple way to avoid this pitfall is to either use `Raw` as the last
definition, or to always have it under a directory. definition, or to always have it under a static path.
``` haskell ``` haskell
type UserAPI15 = "files" :> Raw type UserAPI15 = "files" :> Raw
-- The raw endpoint is under a directory, -- The raw endpoint is under the /files
-- so it won't match /users. -- static path, so it won't match /users.
:<|> "users" :> Get '[JSON] [User] :<|> "users" :> Get '[JSON] [User]
type UserAPI16 = "users" :> Get '[JSON] [User] type UserAPI16 = "users" :> Get '[JSON] [User]