@@ -148,19 +148,26 @@ instance Hashable Method
149-- λ> 'defEndpoint'
149-- λ> 'defEndpoint'
151−-- λ> 'defEndpoint' & 'path' '<>~' "foo"
151+-- λ> 'defEndpoint' & 'path' '<>~' ["foo"]
152-- GET /foo
152-- GET /foo
153−-- λ> 'defEndpoint' & 'path' '<>~' "foo" & 'method' '.~' 'DocPOST'
153+-- λ> 'defEndpoint' & 'path' '<>~' ["foo"] & 'method' '.~' 'DocPOST'
154-- POST /foo
154-- POST /foo
156data Endpoint = Endpoint
156data Endpoint = Endpoint
157− { _path :: String -- type collected
157+ { _path :: [String] -- type collected
158− , _method :: Method -- type collected
158+ , _method :: Method -- type collected
159 } deriving (Eq, Generic)
159 } deriving (Eq, Generic)
161instance Show Endpoint where
161instance Show Endpoint where
162 show (Endpoint p m) =
162 show (Endpoint p m) =
163− show m ++ " " ++ p
163+ show m ++ " " ++ showPath p
166+-- Render a path as a '/'-delimited string
168+showPath :: [String] -> String
170+showPath ps = concatMap ('/' :) ps
165-- | An 'Endpoint' whose path is `"/"` and whose method is 'DocGET'
172-- | An 'Endpoint' whose path is `"/"` and whose method is 'DocGET'
@@ -169,13 +176,13 @@ instance Show Endpoint where
170-- λ> 'defEndpoint'
177-- λ> 'defEndpoint'
172−-- λ> 'defEndpoint' & 'path' '<>~' "foo"
179+-- λ> 'defEndpoint' & 'path' '<>~' ["foo"]
173-- GET /foo
180-- GET /foo
174−-- λ> 'defEndpoint' & 'path' '<>~' "foo" & 'method' '.~' 'DocPOST'
181+-- λ> 'defEndpoint' & 'path' '<>~' ["foo"] & 'method' '.~' 'DocPOST'
175-- POST /foo
182-- POST /foo
177defEndpoint :: Endpoint
184defEndpoint :: Endpoint
178−defEndpoint = Endpoint "/" DocGET
185+defEndpoint = Endpoint [] DocGET
180instance Hashable Endpoint
187instance Hashable Endpoint
@@ -376,7 +383,7 @@ markdown = unlines . concat . map (uncurry printEndpoint) . HM.toList
376 responseStr (action ^. response) ++
383 responseStr (action ^. response) ++
379− where str = show (endpoint^.method) ++ " " ++ endpoint^.path
386+ where str = show (endpoint^.method) ++ " " ++ showPath (endpoint^.path)
380 len = length str
387 len = length str
382 capturesStr :: [DocCapture] -> [String]
389 capturesStr :: [DocCapture] -> [String]
@@ -472,7 +479,7 @@ instance (KnownSymbol sym, ToCapture (Capture sym a), HasDocs sublayout)
472 captureP = Proxy :: Proxy (Capture sym a)
479 captureP = Proxy :: Proxy (Capture sym a)
474 action' = over captures (|> toCapture captureP) action
481 action' = over captures (|> toCapture captureP) action
475− endpoint' = over path (\p -> p++"/:"++symbolVal symP) endpoint
482+ endpoint' = over path (\p -> p ++ [":" ++ symbolVal symP]) endpoint
476 symP = Proxy :: Proxy sym
483 symP = Proxy :: Proxy sym
@@ -577,7 +584,7 @@ instance (KnownSymbol path, HasDocs sublayout) => HasDocs (path :> sublayout) wh
577 docsFor sublayoutP (endpoint', action)
584 docsFor sublayoutP (endpoint', action)
579 where sublayoutP = Proxy :: Proxy sublayout
586 where sublayoutP = Proxy :: Proxy sublayout
580− endpoint' = endpoint & path <>~ symbolVal pa
587+ endpoint' = endpoint & path <>~ [symbolVal pa]
581 pa = Proxy :: Proxy path
588 pa = Proxy :: Proxy path