type ItemApi =
-- GET /item
"item" :> Get '[JSON] [Item] :<|>
-- GET /item/:itemId
"item" :> Capture "itemId" Integer :> Get '[JSON] Item
getItems :: Handler [Item]
getItems = return [exampleItem]
getItemById :: Integer -> Handler Item
getItemById = \case
0 -> return exampleItem
_ -> throwE err404
server :: Server ItemApi
server = getItems :<|> getItemById
Taken form example-servant-minimal.