-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathDependency.swift
31 lines (26 loc) · 1003 Bytes
/
Dependency.swift
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
import NIOHPACK
public protocol Dependency {
/// It is possible to monitor all requests by injecting it when creating `Session`.
/// Processing can be interrupted as necessary.
///
/// - Parameter headers: HPACKHeaders to be sent
/// - Returns: Metadata changed as necessary
/// - Throws: Error when intercepting request
func intercept(headers: HPACKHeaders) throws -> HPACKHeaders
/// Called when the client catches an error.
///
/// - Parameters:
/// - error: The error which was caught.
/// - file: The file where the error was raised.
/// - line: The line within the file where the error was raised.
func didCatchError(_ error: Error, file: StaticString, line: Int)
}
public extension Dependency {
func intercept(headers: HPACKHeaders) throws -> HPACKHeaders {
headers
}
func didCatchError(_ error: Error, file: StaticString, line: Int) {}
}
public class StreamingDependency: Dependency {
public init() {}
}