createServer
external fun <Request : IncomingMessage, Response : ServerResponse<*>> createServer(requestListener: RequestListener<Request, Response> = definedExternally): Server<Request, Response>(source)
// curl -k https://localhost:8000/
const https = require('node:https');
const fs = require('node:fs');
const options = {
key: fs.readFileSync('test/fixtures/keys/agent2-key.pem'),
cert: fs.readFileSync('test/fixtures/keys/agent2-cert.pem'),
};
https.createServer(options, (req, res) => {
res.writeHead(200);
res.end('hello world\n');
}).listen(8000);
Content copied to clipboard
Or
const https = require('node:https');
const fs = require('node:fs');
const options = {
pfx: fs.readFileSync('test/fixtures/test_cert.pfx'),
passphrase: 'sample',
};
https.createServer(options, (req, res) => {
res.writeHead(200);
res.end('hello world\n');
}).listen(8000);
Content copied to clipboard
Since
v0.3.4
Parameters
options
Accepts options
from createServer
, createSecureContext
and createServer
.
requestListener
A listener to be added to the 'request'
event.
external fun <Request : IncomingMessage, Response : ServerResponse<*>> createServer(options: ServerOptions<Request, Response>, requestListener: RequestListener<Request, Response> = definedExternally): Server<Request, Response>(source)