This repository implements a simple http server on top of deno.
import { listen } from 'https://raw.githubusercontent.com/lenkan/deno-http/v0.0.4/src/http'
listen('127.0.0.1:3000', async (req, res) => {
const encoder = new TextEncoder('utf8')
const body = encoder.encode(JSON.stringify({
request: req
}))
await res
.status(200, 'OK')
.headers({
'Content-Type': 'application/json',
'Content-Length': response.byteLength.toString()
}).send(body)
})
Many specifics, for example Transfer-Encoding
is not implemented.
Install deno per instructions. Generate typings for deno
with:
deno --types > lib.d.ts
Run unit tests with:
deno test.ts
Try the examples with:
deno --allow-net examples/echo.ts
deno --allow-net examples/serve-static.ts