@@ -148,19 +148,26 @@ instance Hashable Method
148148-- @
149149-- λ> 'defEndpoint'
150150-- GET /
151−-- λ> 'defEndpoint' & 'path' '<>~' "foo"
151+-- λ> 'defEndpoint' & 'path' '<>~' ["foo"]
152152-- GET /foo
153−-- λ> 'defEndpoint' & 'path' '<>~' "foo" & 'method' '.~' 'DocPOST'
153+-- λ> 'defEndpoint' & 'path' '<>~' ["foo"] & 'method' '.~' 'DocPOST'
154154-- POST /foo
155155-- @
156156data Endpoint = Endpoint
157− { _path :: String -- type collected
158− , _method :: Method -- type collected
157+ { _path :: [String] -- type collected
158+ , _method :: Method -- type collected
159159 } deriving (Eq, Generic)
160160
161161instance Show Endpoint where
162162 show (Endpoint p m) =
163− show m ++ " " ++ p
163+ show m ++ " " ++ showPath p
164+
165+-- |
166+-- Render a path as a '/'-delimited string
167+--
168+showPath :: [String] -> String
169+showPath [] = "/"
170+showPath ps = concatMap ('/' :) ps
164171
165172-- | An 'Endpoint' whose path is `"/"` and whose method is 'DocGET'
166173--
@@ -169,13 +176,13 @@ instance Show Endpoint where
169176-- @
170177-- λ> 'defEndpoint'
171178-- GET /
172−-- λ> 'defEndpoint' & 'path' '<>~' "foo"
179+-- λ> 'defEndpoint' & 'path' '<>~' ["foo"]
173180-- GET /foo
174−-- λ> 'defEndpoint' & 'path' '<>~' "foo" & 'method' '.~' 'DocPOST'
181+-- λ> 'defEndpoint' & 'path' '<>~' ["foo"] & 'method' '.~' 'DocPOST'
175182-- POST /foo
176183-- @
177184defEndpoint :: Endpoint
178−defEndpoint = Endpoint "/" DocGET
185+defEndpoint = Endpoint [] DocGET
179186
180187instance Hashable Endpoint
181188
@@ -376,7 +383,7 @@ markdown = unlines . concat . map (uncurry printEndpoint) . HM.toList
376383 responseStr (action ^. response) ++
377384 []
378385
379− where str = show (endpoint^.method) ++ " " ++ endpoint^.path
386+ where str = show (endpoint^.method) ++ " " ++ showPath (endpoint^.path)
380387 len = length str
381388
382389 capturesStr :: [DocCapture] -> [String]
@@ -472,7 +479,7 @@ instance (KnownSymbol sym, ToCapture (Capture sym a), HasDocs sublayout)
472479 captureP = Proxy :: Proxy (Capture sym a)
473480
474481 action' = over captures (|> toCapture captureP) action
475− endpoint' = over path (\p -> p++"/:"++symbolVal symP) endpoint
482+ endpoint' = over path (\p -> p ++ [":" ++ symbolVal symP]) endpoint
476483 symP = Proxy :: Proxy sym
477484
478485
@@ -577,7 +584,7 @@ instance (KnownSymbol path, HasDocs sublayout) => HasDocs (path :> sublayout) wh
577584 docsFor sublayoutP (endpoint', action)
578585
579586 where sublayoutP = Proxy :: Proxy sublayout
580− endpoint' = endpoint & path <>~ symbolVal pa
587+ endpoint' = endpoint & path <>~ [symbolVal pa]
581588 pa = Proxy :: Proxy path
582589
583590{-