on 286b1db help sign in
38 lines 1.2 kB history raw
1{-# LANGUAGE InstanceSigs #-}
2{-# LANGUAGE OverloadedStrings #-}
3{-# LANGUAGE TypeFamilies #-}
4module Servant.API.Raw where
6import Control.Monad.Trans.Either
7import Data.ByteString.Lazy
8import Data.Proxy
9import Network.HTTP.Types
10import Network.Wai
11import Servant.Client
12import Servant.Common.BaseUrl
13import Servant.Common.Req
14import Servant.Docs hiding (Method)
15import Servant.Server
17-- | Endpoint for plugging in your own Wai 'Application's.
18--
19-- The given 'Application' will get the request as received by the server, potentially with
20-- a modified (stripped) 'pathInfo' if the 'Application' is being routed with 'Servant.API.Sub.:>'.
21data Raw
23instance HasServer Raw where
24 type Server Raw = Application
25 route Proxy rawApplication request respond =
26 rawApplication request (respond . succeedWith)
28instance HasClient Raw where
29 type Client Raw = Method -> BaseUrl -> EitherT String IO (Int, ByteString)
31 clientWithRoute :: Proxy Raw -> Req -> Client Raw
32 clientWithRoute Proxy req method host =
33 performRequest method req (const True) host
36instance HasDocs Raw where
37 docsFor _proxy (endpoint, action) =
38 single endpoint action