0 | module HTTP.API.Client.Request
3 | import Web.Internal.Types
10 | data FDPart : Type where
11 | FDBlob : Blob -> FDPart
12 | FDBytes : ByteString -> FDPart
13 | FDFile : File -> FDPart
14 | FDString : String -> FDPart
17 | data RequestBody : Type where
19 | Bytes : MediaType -> ByteString -> RequestBody
20 | Str : MediaType -> String -> RequestBody
21 | FD : List (String,FDPart) -> RequestBody
24 | record HTTPRequest where
32 | adjURI : (URI -> URI) -> HTTPRequest -> HTTPRequest
33 | adjURI f = {uri $= f}
36 | emptyRequest : HTTPRequest
38 | R GET (MkURI Nothing Nothing False [] [] Nothing) emptyHeaders None
45 | interface RequestEncode (0 from,to : Type) where
46 | reqEncodeAs : from -> to
47 | toBody : to -> RequestBody
50 | (e : EncodeVia f t) => RequestEncode f t where
51 | reqEncodeAs = encodeAs
52 | toBody = Bytes (mediaType @{e}) . fastConcat . toBytes @{e}