Skip to content
This repository has been archived by the owner on May 5, 2020. It is now read-only.

lenkan/deno-http

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

deno-http

This repository implements a simple http server on top of deno.

Usage

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)
})

Status

Many specifics, for example Transfer-Encoding is not implemented.

Development

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

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

No packages published