New Project
Deno has a built in HTTP server API that allows you to write HTTP/1.1
and HTTP/2
servers.
Starting the project
VSCode
Inside VSCode you may want to execute:
This will create a .vscode
on the project to enable Deno extension to work.
Serving content
HTTP/2
support is "automatic" when using the HTTP server APIs with Deno.
You just need to create your server, and it will handle HTTP/1
or HTTP/2
requests seamlessly.
The HTTP server has built in automatic compression of response bodies. (Supporting gzip
and brotli
compression)
Check some conditions for this automatic compression here.
Simple content
By default Deno will listen on port 8000
.
req.text()
call and ALL other methods that read from the Request Body can fail if the user hangs up the connection before the body is fully received.
Make sure to handle this case.
For HTTPS
make sure to add two more parameters.
Streaming content
Check an example here.
Deno can upgrade incoming HTTP requests to a WebSocket.
Note that WebSockets are only supported on HTTP/1.1
for now.
Running
Don't forget to give the --allow-net
permissions.
Last updated