1{-# LANGUAGE PolyKinds #-}
2{-# LANGUAGE TypeFamilies #-}
3{-# LANGUAGE TypeOperators #-}
4{-# LANGUAGE FlexibleContexts #-}
5{-# LANGUAGE FlexibleInstances #-}
6{-# LANGUAGE ScopedTypeVariables #-}
7module Servant.API.Capture where
15import Servant.Common.Req
16import Servant.Common.Text
23captured :: FromText a => proxy (Capture sym a) -> Text -> Maybe a
26instance (KnownSymbol capture, FromText a, HasServer sublayout)
27 => HasServer (Capture capture a :> sublayout) where
29 type Server (Capture capture a :> sublayout) =
32 route Proxy subserver request respond = case pathInfo request of
34 -> case captured captureProxy first of
35 Nothing -> respond $ failWith NotFound
36 Just v -> route (Proxy :: Proxy sublayout) (subserver v) request{
39 _ -> respond $ failWith NotFound
41 where captureProxy = Proxy :: Proxy (Capture capture a)
43instance (KnownSymbol capture, ToText a, HasClient sublayout)
44 => HasClient (Capture capture a :> sublayout) where
46 type Client (Capture capture a :> sublayout) =
49 clientWithRoute Proxy req val =
50 clientWithRoute (Proxy :: Proxy sublayout) $
53 where p = unpack (toText val)
55instance (KnownSymbol sym, ToCapture (Capture sym a), HasDocs sublayout)
56 => HasDocs (Capture sym a :> sublayout) where
58 docsFor Proxy (endpoint, action) =
59 docsFor sublayoutP (endpoint', action')
61 where sublayoutP = Proxy :: Proxy sublayout
62 captureP = Proxy :: Proxy (Capture sym a)
64 action' = over captures (|> toCapture captureP) action
65 endpoint' = over path (\p -> p++"/:"++symbolVal symP) endpoint
66 symP = Proxy :: Proxy sym
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