0 | module HTTP.API.Client.Path
 1 |
 2 | import HTTP.API.Client.Interface
 3 |
 4 | %default total
 5 |
 6 | export
 7 | recTypes : (ps : List Part) -> TList (PartsTypes ps)
 8 | recTypes []                = []
 9 | recTypes (PStr _    :: xs) = recTypes xs
10 | recTypes (PTill _   :: xs) = recTypes xs
11 | recTypes (Capture t :: xs) = t :: recTypes xs
12 |
13 | reqPath :
14 |      (ps : List Part)
15 |   -> All EncodeMany (PartsTypes ps)
16 |   -> HList (PartsTypes ps)
17 |   -> List ByteString
18 | reqPath []        _  _  = []
19 | reqPath (PStr s    :: ps) es      vs      = fromString s :: reqPath ps es vs
20 | reqPath (PTill s   :: ps) es      vs      = fromString s :: reqPath ps es vs
21 | reqPath (Capture _ :: ps) (e::es) (v::vs) = encodeMany v ++ reqPath ps es vs
22 |
23 | public export
24 | Receive ReqPath where
25 |   RecConstraint p = All EncodeMany (PartsTypes p.parts)
26 |   RecTypes p = PartsTypes p.parts
27 |   recs p = recTypes p.parts
28 |   adjRequest p vs r =
29 |     let pth := reqPath p.parts con vs
30 |      in adjURI {path := pth} r
31 |
32 | public export
33 | GetResponse ReqPath where
34 |   RespEncodings _ = []
35 |   RespTypes _ = []
36 |