Skip to content

Commit 8555936

Browse files
committed
docs: add definition of terms
1 parent b80b02e commit 8555936

File tree

1 file changed

+24
-14
lines changed

1 file changed

+24
-14
lines changed

README.md

+24-14
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,17 @@ Define standard HTTP middleware specifications. This is intended to increase the
88
interoperability of the HTTP library's own middleware.
99

1010
It consists only of the web standards stack and is compatible with many
11-
Browsers.
11+
browsers.
12+
13+
## Terms
14+
15+
<dl>
16+
<dt>Upstream</dt>
17+
<dd>Refers to HTTP requests forwarded from the client to the server.</dd>
18+
19+
<dt>Downstream</dt>
20+
<dd>Refers to the HTTP response forwarded from the server to the client.</dd>
21+
</dl>
1222

1323
## Interface
1424

@@ -28,25 +38,25 @@ interface Handler {
2838

2939
`Middleware` has the following features:
3040

31-
- Compatible with `Handler`.
41+
- Compliant with [Fetch API](https://fetch.spec.whatwg.org/).
42+
- Compliant with `Handler`.
3243

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

36-
- It can access to the `Request`.
37-
- It can access the next handler.
38-
- It can call the next handler.
39-
- It can choose not to call the next handler.
40-
- It can access the next handler's return value (`Response`).
41-
- It can return `Response`.
47+
- It is a pure function.
48+
49+
`Middleware` is a pure function that returns a value. Implementations are
50+
expected to have no side effects.
51+
- It is self-contained.
52+
- It can handle upstream.
53+
- It can handle downstream.
54+
- It can handle next handler.
4255

43-
## Middleware
56+
## Implementation
4457

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

5161
## License
5262

0 commit comments

Comments
 (0)