1{-# LANGUAGE TypeFamilies #-}
2{-# LANGUAGE OverloadedStrings #-}
3module Servant.Server where
6import Network.HTTP.Types
9-- * Implementing Servers
11-- | 'serve' allows you to implement an API and produce a wai 'Application'.
12serve :: HasServer layout => Proxy layout -> Server layout -> Application
13serve p server = toApplication (route p server)
15toApplication :: RoutingApplication -> Application
16toApplication ra = \ request respond -> do
19 Nothing -> respond $ responseLBS notFound404 [] "not found"
20 Just response -> respond response
22type RoutingApplication =
23 Request -> IO (Maybe Response)
25class HasServer layout where
26 type Server layout :: *
27 route :: Proxy layout -> Server layout -> RoutingApplication
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list