@@ -15,9 +15,17 @@ import Servant.Server
16-- | The contained API (second argument) can be found under @("/" ++ path)@
16-- | The contained API (second argument) can be found under @("/" ++ path)@
17-- (path being the first argument).
17-- (path being the first argument).
21+-- > -- GET /hello/world
22+-- > -- returning a JSON encoded World value
23+-- > type MyApi = "hello" :> "world" :> Get World
18data (path :: k) :> a = Proxy path :> a
24data (path :: k) :> a = Proxy path :> a
19infixr 9 :>
25infixr 9 :>
27+-- | Make sure the incoming request starts with @"/path"@, strip it and
28+-- pass the rest of the request path to @sublayout@.
21instance (KnownSymbol path, HasServer sublayout) => HasServer (path :> sublayout) where
29instance (KnownSymbol path, HasServer sublayout) => HasServer (path :> sublayout) where
22 type Server (path :> sublayout) = Server sublayout
30 type Server (path :> sublayout) = Server sublayout
23 route Proxy subserver request respond = case pathInfo request of
31 route Proxy subserver request respond = case pathInfo request of
@@ -30,6 +38,7 @@ instance (KnownSymbol path, HasServer sublayout) => HasServer (path :> sublayout
31 where proxyPath = Proxy :: Proxy path
39 where proxyPath = Proxy :: Proxy path
41+-- | Make the querying function append @path@ to the request path.
33instance (KnownSymbol path, HasClient sublayout) => HasClient (path :> sublayout) where
42instance (KnownSymbol path, HasClient sublayout) => HasClient (path :> sublayout) where
34 type Client (path :> sublayout) = Client sublayout
43 type Client (path :> sublayout) = Client sublayout