@@ -35,15 +35,17 @@ import Data.Text.Encoding (decodeUtf8, encodeUtf8)
3535import Data.Typeable
3636import GHC.TypeLits (KnownSymbol, symbolVal)
3737import Network.HTTP.Types hiding (Header, ResponseHeaders)
38+import Network.Socket (SockAddr)
3839import Network.Wai (Application, lazyRequestBody,
3940 rawQueryString, requestHeaders,
40− requestMethod, responseLBS)
41+ requestMethod, responseLBS, remoteHost,
42+ isSecure, vault, httpVersion)
4143import Servant.API ((:<|>) (..), (:>), Capture,
42− Delete, Get, Header,
43− MatrixFlag, MatrixParam, MatrixParams,
44− Patch, Post, Put, QueryFlag,
45− QueryParam, QueryParams, Raw,
46− ReqBody)
44+ Delete, Get, Header,
45+ IsSecure(..), MatrixFlag, MatrixParam,
46+ MatrixParams, Patch, Post, Put,
47+ QueryFlag, QueryParam, QueryParams,
48+ Raw, RemoteHost, ReqBody, Vault)
4749import Servant.API.ContentTypes (AcceptHeader (..),
4850 AllCTRender (..),
4951 AllCTUnrender (..))
@@ -721,5 +723,31 @@ instance (KnownSymbol path, HasServer sublayout) => HasServer (path :> sublayout
721723 (route (Proxy :: Proxy sublayout) subserver)
722724 where proxyPath = Proxy :: Proxy path
723725
726+instance HasServer api => HasServer (RemoteHost :> api) where
727+ type ServerT (RemoteHost :> api) m = SockAddr -> ServerT api m
728+
729+ route Proxy subserver = WithRequest $ \req ->
730+ route (Proxy :: Proxy api) (feedTo subserver $ remoteHost req)
731+
732+instance HasServer api => HasServer (IsSecure :> api) where
733+ type ServerT (IsSecure :> api) m = IsSecure -> ServerT api m
734+
735+ route Proxy subserver = WithRequest $ \req ->
736+ route (Proxy :: Proxy api) (feedTo subserver $ secure req)
737+
738+ where secure req = if isSecure req then Secure else NotSecure
739+
740+instance HasServer api => HasServer (Vault :> api) where
741+ type ServerT (Vault :> api) m = Vault -> ServerT api m
742+
743+ route Proxy subserver = WithRequest $ \req ->
744+ route (Proxy :: Proxy api) (feedTo subserver $ vault req)
745+
746+instance HasServer api => HasServer (HttpVersion :> api) where
747+ type ServerT (HttpVersion :> api) m = HttpVersion -> ServerT api m
748+
749+ route Proxy subserver = WithRequest $ \req ->
750+ route (Proxy :: Proxy api) (feedTo subserver $ httpVersion req)
751+
724752ct_wildcard :: B.ByteString
725753ct_wildcard = "*" <> "/" <> "*" -- Because CPP