File tree 1 file changed +21
-0
lines changed
1 file changed +21
-0
lines changed Original file line number Diff line number Diff line change 15
15
- [ Response Middleware] ( #response-middleware )
16
16
- [ Async operations] ( #async-operations )
17
17
- [ Debugging Koa] ( #debugging-koa )
18
+ - [ HTTP2] ( #http2 )
18
19
19
20
## Writing Middleware
20
21
@@ -246,3 +247,23 @@ app.use(publicFiles);
246
247
```
247
248
koa:application use static /public +0ms
248
249
```
250
+
251
+ ## HTTP2
252
+
253
+ Example of setting up an HTTP2 server with Koa using the HTTP compatibility layer:
254
+
255
+ ``` js
256
+ import Koa from ' koa'
257
+ import http2 from ' node:http2'
258
+ import fs from ' node:fs'
259
+
260
+ const app = new Koa ();
261
+
262
+ const onRequestHandler = app .callback ();
263
+ const serverOptions = {
264
+ key: fs .readFileSync (' key.pem' ),
265
+ cert: fs .readFileSync (' cert.pem' )
266
+ }
267
+
268
+ const server = http2 .createSecureServer (serverOptions, onRequestHandler);
269
+ ```
You can’t perform that action at this time.
0 commit comments