-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtypes.ts
More file actions
35 lines (30 loc) · 913 Bytes
/
types.ts
File metadata and controls
35 lines (30 loc) · 913 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
// Copyright 2023-latest the httpland authors. All rights reserved. MIT license.
// This module is browser compatible.
import { type Handler } from "./deps.ts";
/** Chainable HTTP handlers.
* Accepts `Request` and the next HTTP handlers.
*/
export interface ChainableHandler {
(
request: Request,
next: OptionalHandler,
): Response | Promise<Response>;
}
/** Optional `Request` HTTP handler.
* It is possible not to pass the `Request` object.
*/
export interface OptionalHandler {
(request?: Request): Response | Promise<Response>;
}
/** Chainable HTTP handler API. */
export interface Chainable {
/** Register chainable HTTP handlers. */
readonly next: (...handlers: readonly ChainableHandler[]) => this;
}
/** HTTP responsive API.
* Accept `Request` and respond `Response`.
*/
export interface Responsive {
/** Respond `Response` from `Request`. */
readonly respond: Handler;
}