You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: springboot2-request-logger/README.md
+51Lines changed: 51 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -62,3 +62,54 @@ You may run [testControllerLoggingWithFilter](./src/test/java/com/bvn13/example/
62
62
63
63
So our goal is achieved. We can see all files we request and not existing file too.
64
64
65
+
66
+
## Building a Handler Interceptor
67
+
68
+
Handler interceptors have more power to process your requests since they handle not the fact of request but its events: before request, after request, after completion.
69
+
70
+
You can check out Spring class `org.springframework.web.servlet.handler.HandlerInterceptorAdapter` to see its methods we are able to implement in our handler.
71
+
72
+
Lets [our handler](/src/main/java/com/bvn13/example/springboot/springrequestlogger/handlers/RequestLoggingHandler.java) implement `preHandle` and `postHandle` events:
But the handler will not work until we actually tell Spring to use it. We must build a [configuration](/src/main/java/com/bvn13/example/springboot/springrequestlogger/handlers/WebApplicationConfiguration.java) to enable our handler.
0 commit comments