Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/sant123/connect

Powerful and extensible router for Deno with std/http in mind
https://github.com/sant123/connect

connect http-server middleware route routing

Last synced: 22 days ago
JSON representation

Powerful and extensible router for Deno with std/http in mind

Awesome Lists containing this project

README

        

# Connect
Powerful and extensible router for Deno with std/http in mind

``` ts
import { serve } from "https://deno.land/[email protected]/http/server.ts";
import { Connect } from "https://deno.land/x/connect/mod.ts";

const app = new Connect();

app.handleNotFound = () => {
return new Response("The page you are looking for is not here :)", {
status: 404,
});
};

app.get("/", () => {
return new Response("Hello world!");
});

app.map({
"/contact": () => {
return new Response("Hello from contact page!");
},
});

app.route("/shop")
.get(() => {
return new Response("Hello from shop page!");
});

serve(app.handler, { port: 8080 });

```