xcto-middleware

deno land deno doc GitHub release (latest by date) codecov GitHub

test NPM

HTTP XCTO(X-Content-Type-Options) middleware.

Compliant with Fetch, 3.5. X-Content-Type-Options header.

Middleware

For a definition of Universal HTTP middleware, see the http-middleware project.

Usage

Middleware adds the X-Content-Type-Options header to the response.

import {
  type Handler,
  xcto,
} from "https://deno.land/x/xcto_middleware@$VERSION/mod.ts";
import { assert } from "https://deno.land/std/testing/asserts.ts";

declare const request: Request;
declare const handler: Handler;

const middleware = xcto();
const response = await middleware(request, handler);

assert(response.headers.has("x-content-type-options"));

yield:

X-Content-Type-Options: nosniff

Conditions

Middleware is executed if all of the following conditions are met:

  • Response does not include X-Content-Type-Options header

Effects

Middleware may make changes to the following elements of the HTTP message.

  • HTTP Headers
    • X-Content-Type-Options

API

All APIs can be found in the deno doc.

License

Copyright © 2023-present httpland.

Released under the MIT license