import { type Router } from "https://deno.land/x/servest@v1.3.4/mod.ts";
Methods
Set global middleware. It will be called for each request on any routes.
Register route with given pattern. It will be called for every http method, Examples: router.handle("/", ...) => Called if request path exactly matches "/". router.handle(/^//, ...) => Called if request path matches given regexp.
Register route with given prefixer. This is similar to router.handle() but different in several points:
- Only string prefix can be passed.
- Handlers will be called if req.path STARTS WITH prefix
- route() doesn't designate a single route handler set before dispatching. This means it will keep calling all handler sets that matches prefixer until someone responds.
- route can accept Router Examples router.route("/users", ...) => Called if request path STARTS WITH "/users".
Register GET/HEAD route. This is shortcut for handle();
Register POST route. This is shortcut for handle()
Set global error handler. All unhandled promise rejections occured on processing requests will be passed . Only one handler can be set for one router.
Set global finalizer. Every request will reach this handler. Note that request may already has been responded by other handlers. Only one handler can be set for one router.