Skip to content

Commit

Permalink
docs: add definition of terms
Browse files Browse the repository at this point in the history
  • Loading branch information
TomokiMiyauci committed Mar 16, 2023
1 parent b80b02e commit 8555936
Showing 1 changed file with 24 additions and 14 deletions.
38 changes: 24 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,17 @@ 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.
browsers.

## Terms

<dl>
<dt>Upstream</dt>
<dd>Refers to HTTP requests forwarded from the client to the server.</dd>

<dt>Downstream</dt>
<dd>Refers to the HTTP response forwarded from the server to the client.</dd>
</dl>

## Interface

Expand All @@ -28,25 +38,25 @@ interface Handler {

`Middleware` has the following features:

- Compatible with `Handler`.
- 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 can access to the `Request`.
- It can access the next handler.
- It can call the next handler.
- It can choose not to call the next handler.
- It can access the next handler's return value (`Response`).
- It can return `Response`.
- 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.

## Middleware
## Implementation

- [http-cors](https://github.com/httpland/http-cors) - Enable CORS
- [http-log](https://github.com/httpland/http-log) - Log for request and
response
- [http-etag](https://github.com/httpland/http-etag) - ETag calculate and
validate
See [chain-handler](https://github.com/httpland/chain-handler) for a concrete
implementation that can handle middleware

## License

Expand Down

0 comments on commit 8555936

Please sign in to comment.