0 | module Node.HTTP.Static
3 | import Node.HTTP.CreateServer
4 | import Node.HTTP.ClientRequest
5 | import Node.HTTP.IncomingMessage
6 | import public Node.HTTP.Request
7 | import Node.HTTP.Server as HTTP
8 | import Node.HTTP.Module
9 | import Node.Net.Socket.Type
10 | import Node.Net.Socket.Connect
12 | %foreign "node:lambda: (http, url, t, opts, cb) => http.get(url, opts, (res) => { cb(res)() })"
13 | ffi_get : HTTPModule -> String -> (t : SocketType) -> Node (Request.Command.Options t) -> (IncomingMessage -> PrimIO ()) -> PrimIO ClientRequest
16 | (.get) : HasIO io => HTTPModule -> String -> {auto t : SocketType } -> Request.Command.Options t -> (IncomingMessage -> IO ()) -> io ClientRequest
17 | (.get) http url {t} opts cb = primIO $
ffi_get http url t (convertOptions t opts) $
\res => toPrim $
cb res
19 | %foreign "node:lambda: (http, url, t, opts, cb) => http.request(url, opts, (res) => { cb(res)() })"
20 | ffi_request : HTTPModule -> String -> (t : SocketType) -> Node (Request.Command.Options t) -> (IncomingMessage -> PrimIO ()) -> PrimIO ClientRequest
23 | (.request) : HasIO io => HTTPModule -> String -> {auto t : SocketType} -> Request.Command.Options t -> (IncomingMessage -> IO ()) -> io ClientRequest
24 | (.request) http url {t} opts cb = primIO $
ffi_request http url t (convertOptions t opts) $
\res => toPrim $
cb res
27 | (.post) : HasIO io => HTTPModule -> String -> {auto t : SocketType} -> Request.Command.Options t -> (IncomingMessage -> IO ()) -> io ClientRequest
28 | (.post) http url opts cb = http.request url ({ request.method := "POST" } opts) cb
30 | %foreign "node:lambda: (http, options) => http.createServer(options)"
31 | ffi_createServer : HTTPModule -> Node CreateServer.Options -> PrimIO HTTP.Server
34 | (.createServer) : HasIO io => HTTPModule -> CreateServer.Options -> io HTTP.Server
35 | (.createServer) http options = primIO $
ffi_createServer http $
convertOptions options