Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@httpland/http-middleware

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@httpland/http-middleware

HTTP middleware specification

  • 1.0.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

http-middleware

HTTP middleware specification

What

Define standard HTTP middleware specifications. This is intended to increase the interoperability of the HTTP library's own middleware.

It consists only of the web standards stack and is compatible with many browsers.

Terms

Upstream
Refers to HTTP requests forwarded from the client to the server.
Downstream
Refers to the HTTP response forwarded from the server to the client.

Interface

Middleware interfaces can be defined in TypeScript as follows:

interface Middleware {
  (request: Request, next: Handler): Response | Promise<Response>;
}

interface Handler {
  (request: Request): Response | Promise<Response>;
}

Features

Middleware has the following features:

  • Compliant with Fetch API.

  • Compliant with Handler.

    Handler is a powerful interface for handling HTTP requests. The Middleware is purely an extension and compatibility with Handler.

  • It is a pure function.

    Middleware is a pure function that returns a value. Implementations are expected to have no side effects.

  • It is self-contained.

  • It can handle upstream.

  • It can handle downstream.

  • It can handle next handler.

Implementation

See chain-handler for a concrete implementation that can handle middleware

License

Copyright © 2023-present httpland.

Released under the MIT license

Keywords

FAQs

Package last updated on 16 Mar 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc