0 | module HTTP.API.Client.Request
3 | import Web.Internal.Types
7 | %hide JS.ByteString.ByteString
12 | data FDPart : Type where
13 | FDBlob : Blob -> FDPart
14 | FDBytes : ByteString -> FDPart
15 | FDFile : File -> FDPart
16 | FDString : String -> FDPart
19 | data RequestBody : Type where
21 | Blob : MediaType -> Blob -> RequestBody
22 | Bytes : MediaType -> ByteString -> RequestBody
23 | Str : MediaType -> String -> RequestBody
24 | FD : List (String,FDPart) -> RequestBody
27 | record HTTPRequest where
35 | adjURI : (URI -> URI) -> HTTPRequest -> HTTPRequest
36 | adjURI f = {uri $= f}
39 | emptyRequest : HTTPRequest
41 | R GET (MkURI Nothing Nothing False [] [] Nothing) emptyHeaders None
48 | interface RequestEncode (0 from,to : Type) where
49 | reqEncodeAs : from -> to
50 | toBody : to -> RequestBody
53 | (e : EncodeVia f t) => RequestEncode f t where
54 | reqEncodeAs = encodeAs
55 | toBody = Bytes (mediaType @{e}) . fastConcat . toBytes @{e}
58 | RequestEncode Blob Blob where
60 | toBody = Blob applicationOctettStream
63 | RequestEncode File Blob where
64 | reqEncodeAs f = up f
65 | toBody = Blob applicationOctettStream