Routing maps URL paths and HTTP requests to API operations. In Servant, a route is encoded as a type, using path segments, request descriptions, response types, and combinators. section 17.1.1
Build a route from these pieces:
- Use string type-level segments such as "entries" or "add" to describe the URL path. section 17.1.1
- Use :> to attach request and response information, such as Get '[JSON] [TodoEntry] or ReqBody '[JSON] TodoEntry. section 17.1.1
- Use :<|> to combine several endpoint descriptions into one API. section 17.1.1
- Use Capture to keep a variable path segment, such as an integer todo identifier. section 17.1.1
Todo-list routes
A typed API can expose GET /entries, POST /add with a JSON TodoEntry body, and PATCH /toggle/:id with an integer capture. Servant can reject request bodies that do not match the declared specification. section 17.1.1





















