@httpland/xcto-middleware
TypeScript icon, indicating that this package has built-in type declarations

1.0.0 • Public • Published

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

Package Sidebar

Install

npm i @httpland/xcto-middleware

Weekly Downloads

8

Version

1.0.0

License

MIT

Unpacked Size

10.2 kB

Total Files

17

Last publish

Collaborators

  • miyauci