0 | module Node.HTTPS.Static
 1 |
 2 | import Node
 3 | import public Node.HTTP.ClientRequest
 4 | import Node.HTTPS.CreateServer
 5 | import public Node.HTTPS.Request
 6 | import Node.HTTPS.Server as HTTPS
 7 | import Node.HTTPS.Module
 8 |
 9 | %foreign "node:lambda: (https, opts) => https.createServer(opts)"
10 | ffi_createServer : HTTPSModule -> Node HTTPS.CreateServer.Command.Options -> PrimIO HTTPS.Server
11 |
12 | export
13 | (.createServer) : HasIO io => HTTPSModule -> HTTPS.CreateServer.Command.Options -> io HTTPS.Server
14 | (.createServer) https opts = primIO $ ffi_createServer https $ convertOptions opts
15 |
16 | %foreign "node:lambda: (https, url, t, opts, cb) => https.get(url, opts, (res) => { cb(res)() })"
17 | ffi_get : HTTPSModule -> String -> (t : SocketType) -> Node (Node.HTTPS.Request.Command.Options t) -> (IncomingMessage -> PrimIO ()) -> PrimIO ClientRequest
18 |
19 | export
20 | (.get) : HasIO io => HTTPSModule -> String -> { auto t : SocketType } -> Node.HTTPS.Request.Command.Options t -> (IncomingMessage -> IO ()) -> io ClientRequest
21 | (.get) https url {t} opts cb = primIO $ ffi_get https url t (convertOptions t opts) $ \res => toPrim $ cb res
22 |
23 | %foreign "node:lambda: (https, url, t, opts, cb) => https.request(url, opts, (res) => { cb(res)() })"
24 | ffi_request : HTTPSModule -> String -> (t : SocketType) -> Node (Node.HTTPS.Request.Command.Options t) -> (IncomingMessage -> PrimIO ()) -> PrimIO ClientRequest
25 |
26 | export
27 | (.request) : HasIO io => HTTPSModule -> String -> { auto t : SocketType } -> Node.HTTPS.Request.Command.Options t -> (IncomingMessage -> IO ()) -> io ClientRequest
28 | (.request) https url {t} opts cb = primIO $ ffi_request https url t (convertOptions t opts) $ \res => toPrim $ cb res
29 |
30 | export
31 | (.post) : HasIO io => HTTPSModule -> String -> {auto t : SocketType} -> (Node.HTTPS.Request.Command.Options t) -> (IncomingMessage -> IO ()) -> io ClientRequest
32 | (.post) https url opts cb = https.request url ({ request.method := "POST" } opts) cb
33 |
34 |