-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
37 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,30 +1,16 @@ | ||
package com.renaghan.todo; | ||
|
||
import com.renaghan.todo.tracing.TracingEvent; | ||
|
||
import org.springframework.context.ApplicationEventPublisher; | ||
import org.springframework.stereotype.Controller; | ||
import org.springframework.web.bind.annotation.GetMapping; | ||
import org.springframework.web.bind.annotation.RequestMapping; | ||
|
||
import java.security.Principal; | ||
|
||
@Controller | ||
@RequestMapping("/") | ||
public class IndexController { | ||
|
||
private final ApplicationEventPublisher eventPublisher; | ||
|
||
public IndexController(ApplicationEventPublisher eventPublisher) { | ||
this.eventPublisher = eventPublisher; | ||
} | ||
|
||
@GetMapping | ||
@RequestMapping("/") | ||
public String getIndex(Principal principal) { | ||
this.eventPublisher.publishEvent( | ||
new TracingEvent(this, "index", principal != null ? principal.getName() : "anonymous")); | ||
|
||
public String getIndex() { | ||
return "index"; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
9 changes: 8 additions & 1 deletion
9
app/src/main/java/com/renaghan/todo/config/LoggingContextConfiguration.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,21 @@ | ||
package com.renaghan.todo.config; | ||
|
||
import org.springframework.context.ApplicationEventPublisher; | ||
import org.springframework.stereotype.Component; | ||
import org.springframework.web.servlet.config.annotation.InterceptorRegistry; | ||
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; | ||
|
||
@Component | ||
class LoggingContextConfiguration implements WebMvcConfigurer { | ||
|
||
private final ApplicationEventPublisher eventPublisher; | ||
|
||
public LoggingContextConfiguration(ApplicationEventPublisher eventPublisher) { | ||
this.eventPublisher = eventPublisher; | ||
} | ||
|
||
@Override | ||
public void addInterceptors(InterceptorRegistry registry) { | ||
registry.addInterceptor(new LoggingContextInterceptor()); | ||
registry.addInterceptor(new LoggingContextInterceptor(eventPublisher)); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters