function createServer
Usage in Deno
```typescript import { createServer } from "node:node__http2.d.ts"; ```
createServer(onRequestHandler?: (request: Http2ServerRequest,response: Http2ServerResponse,) => void): Http2Server
Returns a `net.Server` instance that creates and manages `Http2Session` instances.
Since there are no browsers known that support [unencrypted HTTP/2](https://http2.github.io/faq/#does-http2-require-encryption), the use of [createSecureServer](../.././node__http2.d.ts/~/createSecureServer) is necessary when
communicating
with browser clients.
```js
import http2 from 'node:http2';
// Create an unencrypted HTTP/2 server.
// Since there are no browsers known that support
// unencrypted HTTP/2, the use of `http2.createSecureServer()`
// is necessary when communicating with browser clients.
const server = http2.createServer();
server.on('stream', (stream, headers) => {
stream.respond({
'content-type': 'text/html; charset=utf-8',
':status': 200,
});
stream.end('
Hello World
'); }); server.listen(8000); ```optional
onRequestHandler: (request: Http2ServerRequest,response: Http2ServerResponse,) => void
See `Compatibility API`
createServer<Http1Request extends IncomingMessage = IncomingMessage,Http1Response extends ServerResponse = ServerResponse,Http2Request extends Http2ServerRequest = Http2ServerRequest,Http2Response extends Http2ServerResponse = Http2ServerResponse,>(options: ServerOptions<Http1Request, Http1Response, Http2Request, Http2Response>,onRequestHandler?: (request: InstanceType<Http2Request>,response: InstanceType<Http2Response>,) => void,): Http2Server<Http1Request, Http1Response, Http2Request, Http2Response>
Http1Request extends IncomingMessage = IncomingMessage
Http1Response extends ServerResponse = ServerResponse
Http2Request extends Http2ServerRequest = Http2ServerRequest
Http2Response extends Http2ServerResponse = Http2ServerResponse
options: ServerOptions<Http1Request, Http1Response, Http2Request, Http2Response>
optional
onRequestHandler: (request: InstanceType<Http2Request>,response: InstanceType<Http2Response>,) => void