Update to ClientMiddleware
kyleroche opened this issue · comments
Kyle Roche commented
I had to update the ClientMIddleware to the following to get this example to run.
struct AuthMiddleware: ClientMiddleware {
let apiKey: String
func intercept(_ request: HTTPRequest, body: HTTPBody?, baseURL: URL, operationID: String, next: (HTTPRequest, HTTPBody?, URL) async throws -> (HTTPResponse, HTTPBody?)) async throws -> (HTTPResponse, HTTPBody?) {
var request = request
request.headerFields.append(
.init(name: HTTPField.Name.authorization, value: "Bearer \(apiKey)")
)
return try await next(request, body, baseURL)
}
}
Kyle Roche commented
also had to import HTTPTypes