@@ -8,7 +8,17 @@ Define standard HTTP middleware specifications. This is intended to increase the
8
8
interoperability of the HTTP library's own middleware.
9
9
10
10
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 >
12
22
13
23
## Interface
14
24
@@ -28,25 +38,25 @@ interface Handler {
28
38
29
39
` Middleware ` has the following features:
30
40
31
- - Compatible with ` Handler ` .
41
+ - Compliant with [ Fetch API] ( https://fetch.spec.whatwg.org/ ) .
42
+ - Compliant with ` Handler ` .
32
43
33
44
` Handler ` is a powerful interface for handling HTTP requests. The ` Middleware `
34
45
is purely an extension and compatibility with ` Handler ` .
35
46
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.
42
55
43
- ## Middleware
56
+ ## Implementation
44
57
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
50
60
51
61
## License
52
62
0 commit comments