https://github.com/httpland/http-middleware
HTTP middleware specification
https://github.com/httpland/http-middleware
fetch fetch-api http http-middleware middleware request response spec specification
Last synced: about 2 months ago
JSON representation
HTTP middleware specification
- Host: GitHub
- URL: https://github.com/httpland/http-middleware
- Owner: httpland
- License: mit
- Created: 2023-02-13T08:59:40.000Z (almost 3 years ago)
- Default Branch: main
- Last Pushed: 2023-03-16T07:43:22.000Z (almost 3 years ago)
- Last Synced: 2025-09-19T20:40:51.339Z (5 months ago)
- Topics: fetch, fetch-api, http, http-middleware, middleware, request, response, spec, specification
- Language: TypeScript
- Homepage: https://deno.land/x/http_middleware
- Size: 10.7 KB
- Stars: 1
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# 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:
```ts
interface Middleware {
(request: Request, next: Handler): Response | Promise;
}
interface Handler {
(request: Request): Response | Promise;
}
```
## Features
`Middleware` has the following features:
- Compliant with [Fetch API](https://fetch.spec.whatwg.org/).
- 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](https://github.com/httpland/chain-handler) for a concrete
implementation that can handle middleware
## License
Copyright © 2023-present [httpland](https://github.com/httpland).
Released under the [MIT](./LICENSE) license