import { type Middleware } from "https://deno.land/x/httpclient@0.0.1/mod.ts";
Define Middlware type
Examples
const empty: Middlware = async (ctx, next) => {
// this is request middleware
console.log("before request processing");
console.log(ctx.url, ctx.options)
await next(); // wait for other middlwares
console.log("after request processing");
const empty: Middlware = async (ctx, next) => { // this is request middleware console.log("before request processing"); console.log(ctx.url, ctx.options) await next(); // wait for other middlwares console.log("after request processing");
// this is response middleware return async (rctx, rnext) => { console.log(ctx.response) console.log("before response processing"); await rnext(); console.log("after request processing"); // modify result ctx.result = null } };
definition: IMiddleware<CtxBase & T>