1{-# LANGUAGE PolyKinds #-}
2{-# LANGUAGE TypeFamilies #-}
3{-# LANGUAGE TypeOperators #-}
4{-# LANGUAGE FlexibleInstances #-}
5{-# LANGUAGE ScopedTypeVariables #-}
6module Servant.API.ReqBody where
8import Control.Applicative
16import Servant.Utils.Req
18-- * Request Body support
21instance (FromJSON a, HasServer sublayout)
22 => HasServer (ReqBody a :> sublayout) where
24 type Server (ReqBody a :> sublayout) =
27 route Proxy subserver request respond = do
28 mrqbody <- decode' <$> lazyRequestBody request
30 Nothing -> respond $ failWith InvalidBody
31 Just v -> route (Proxy :: Proxy sublayout) (subserver v) request respond
33instance (ToJSON a, HasClient sublayout)
34 => HasClient (ReqBody a :> sublayout) where
36 type Client (ReqBody a :> sublayout) =
39 clientWithRoute Proxy req body =
40 clientWithRoute (Proxy :: Proxy sublayout) $
41 setRQBody (encode body) req
43instance (ToSample a, HasDocs sublayout)
44 => HasDocs (ReqBody a :> sublayout) where
46 docsFor Proxy (endpoint, action) =
47 docsFor sublayoutP (endpoint, action')
49 where sublayoutP = Proxy :: Proxy sublayout
51 action' = action & rqbody .~ toSample p
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