0 | module Node.HTTP2.ServerHttp2Stream
 1 |
 2 | import public Data.Buffer
 3 | import public Node.Error
 4 | import public Node.HTTP2.Headers
 5 | import public Node.Stream
 6 |
 7 | export
 8 | data ServerHttp2Stream : Type where [external]
 9 |
10 | public export
11 | implementation ReadableClass Buffer Error ServerHttp2Stream where
12 |
13 | public export
14 | implementation WriteableClass Buffer Error ServerHttp2Stream where
15 |
16 | %foreign "node:lambda: (stream, headers) => stream.respond(headers)"
17 | ffi_respond : ServerHttp2Stream -> Headers -> PrimIO ()
18 |
19 | export
20 | (.respond) : HasIO io => ServerHttp2Stream -> Headers -> io ()
21 | (.respond) stream headers = primIO $ ffi_respond stream headers
22 |
23 | %foreign "node:lambda: (stream) => stream.pushAllowed ? 1 : 0"
24 | ffi_pushAllowed : ServerHttp2Stream -> Int
25 |
26 | export
27 | (.pushAllowed) : ServerHttp2Stream -> Bool
28 | (.pushAllowed) stream = 0 /= ffi_pushAllowed stream
29 |
30 | %foreign """
31 |   node:lambda:
32 |   (stream, headers, callback) => stream.pushStream(headers, (err, str, hs) => callback(err)(str)(hs)())
33 |   """
34 | ffi_pushStream : ServerHttp2Stream -> Headers -> (Error -> ServerHttp2Stream -> Headers -> PrimIO ()) -> PrimIO ()
35 |
36 | export
37 | (.pushStream) : HasIO io => ServerHttp2Stream -> Headers -> (Error -> ServerHttp2Stream -> Headers -> IO ()) -> io ()
38 | (.pushStream) stream headers callback = primIO $ ffi_pushStream stream headers $ \err, str, hs => toPrim $ callback err str hs
39 |
40 |