Replies: 4 comments 5 replies
-
Can you post the code for your middleware and also the code for when you add it to your application |
Beta Was this translation helpful? Give feedback.
-
Currently I'm doing this: struct RequestLogger: HBMiddleware {
func apply(to request: HBRequest, next: HBResponder) -> EventLoopFuture<HBResponse> {
os_log(.debug, log: .mocking, "👻 %@: Received request: %@ %@", String(describing: type(of: self)), String(describing: request.method), request.uri.path)
return next.respond(to: request)
}
}
// Then after starting the server
server.middleware.add(RequestLogger()) |
Beta Was this translation helpful? Give feedback.
-
That's the only middleware I'm using. Looking at using the debugging level. Originally added this middleware only to have the logging look the same as the rest of the code. So I'll take another look at |
Beta Was this translation helpful? Give feedback.
-
OK, I think I've just worked this out. I was adding my middleware after starting the server, assuming that it didn't make any difference. But as I've just found out, if I do that then the responder chain inside the server is setup to call the This appears to be related to the setup done in I had another look at the doco and it doesn't say anything about this (That I could find) so can I suggest adding to the middleware doco to outline that for it to be called before the router it must be added before starting the server. |
Beta Was this translation helpful? Give feedback.
-
So I've setup a number of responses in Hummingbird. Now I'm trying to log the times when a request comes in and no suitable response is found. How can I do that? I tried adding a logging middleware but it only seems to be called if there is a responder found.
Beta Was this translation helpful? Give feedback.
All reactions