1.0.0-beta.3
HTTP request router for standard Request and Response
Attributes
Includes Deno configuration
Repository
Current version released
2 years ago
Versions
- 3.0.0-beta.7Latest
- 3.0.0-beta.6
- 3.0.0-beta.5
- 3.0.0-beta.4
- 3.0.0-beta.3
- 3.0.0-beta.2
- 3.0.0-beta.1
- 2.1.0
- 2.1.0-beta.3
- 2.1.0-beta.2
- 2.1.0-beta.1
- 1.0.0-beta.6
- 2.0.0
- 2.0.0-beta.3
- 2.0.0-beta.2
- 2.0.0-beta.1
- 1.2.0
- 1.2.0-beta.5
- 1.2.0-beta.4
- 1.2.0-beta.3
- 1.2.0-beta.2
- 1.2.0-beta.1
- 1.1.0
- 1.1.0-beta.1
- 1.0.0
- 1.0.0-beta.5
- 1.0.0-beta.4
- 1.0.0-beta.3
- 1.0.0-beta.2
- 1.0.0-beta.1
http-router
HTTP request router for standard Request
and Response
.
- URL pattern matching
- Tiny, lean
Usage
core:
createRouter
- Create HTTP request router.
types:
Method
- HTTP request method.RouteHandler
- A handler for HTTP route requests.Routes
- HTTP request routes.Router
- HTTP request router API.
import { createRouter } from "https://deno.land/x/http_router@$VERSION/mod.ts";
import { serve } from "https://deno.land/std@$VERSION/http/mod.ts";
const router = createRouter({
"/api/students/:name": {
GET: (req, params) => {
const greeting = `Hello! ${params.name!}`;
return new Response(greeting);
},
},
"/api/status": () => new Response("OK"), // Any HTTP request method
});
await serve(router);
Performance
Benchmark script with comparison to several popular routers is available. Run it
with deno bench --unstable
.
License
Copyright © 2022-present httpland.
Released under the MIT license