Skip to main content
Deno 2 is finally here 🎉️
Learn more
Module

x/danet/src/deps.ts>Application#use

A Savory web framework for Deno heavily inspired by Nest
Go to Latest
method Application.prototype.use
import { Application } from "https://deno.land/x/danet@1.3.3/src/deps.ts";

Register middleware to be used with the application. Middleware will be processed in the order it is added, but middleware can control the flow of execution via the use of the next() function that the middleware function will be called with. The context object provides information about the current state of the application.

Basic usage:

const import { Application } from "https://deno.land/x/oak/mod.ts";

const app = new Application();

app.use((ctx, next) => {
  ctx.request; // contains request information
  ctx.response; // setups up information to use in the response;
  await next(); // manages the flow control of the middleware execution
});

await app.listen({ port: 80 });

Type Parameters

optional
S extends State = AS

Parameters

middleware: Middleware<S, Context<S, AS>>
...middlewares: Middleware<S, Context<S, AS>>[]

Returns

Application<S extends AS ? S : (S & AS)>