1{-# LANGUAGE TypeFamilies #-}
2{-# LANGUAGE FlexibleContexts #-}
3{-# LANGUAGE OverloadedStrings #-}
5-- | This module lets you implement 'Server's for defined APIs. You'll
6-- most likely just need 'serve'.
8 ( -- * Run a wai application from an API
11 , -- * Construct a wai Application from an API
14 , -- * Handlers for all standard combinators
19import Data.Proxy (Proxy)
20import Network.Wai (Application)
21import Servant.API (Canonicalize, canonicalize)
22import Servant.Server.Internal
25-- * Implementing Servers
27-- | 'serve' allows you to implement an API and produce a wai 'Application'.
31-- > type MyApi = "books" :> Get '[JSON] [Book] -- GET /books
32-- > :<|> "books" :> ReqBody Book :> Post '[JSON] Book -- POST /books
34-- > server :: Server MyApi
35-- > server = listAllBooks :<|> postBook
36-- > where listAllBooks = ...
37-- > postBook book = ...
39-- > myApi :: Proxy MyApi
42-- > app :: Application
43-- > app = serve myApi server
46-- > main = Network.Wai.Handler.Warp.run 8080 app
47serve :: HasServer (Canonicalize layout) => Proxy layout -> Server layout -> Application
48serve p server = toApplication (route (canonicalize p) server)
50type Server layout = Server' (Canonicalize layout)
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