-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtypes.ts
More file actions
26 lines (23 loc) · 822 Bytes
/
types.ts
File metadata and controls
26 lines (23 loc) · 822 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
// Copyright 2023-latest the httpland authors. All rights reserved. MIT license.
// This module is browser compatible.
/** Precondition API. */
export interface Precondition {
/** Precondition header field name. */
readonly field: string;
/** Definition of precondition evaluation.
* If return value is void, it represents ignore this precondition.
*/
evaluate(
request: Request,
selectedRepresentation: Response,
): boolean | void | Promise<boolean | void>;
/** Called after {@link Precondition.evaluate}.
* If return response, it must not perform the requested method.
* If return value is void, it represents ignore this precondition.
*/
respond(
request: Request,
selectedRepresentation: Response,
result: boolean,
): Response | void | Promise<Response | void>;
}