File tree Expand file tree Collapse file tree 1 file changed +10
-1
lines changed
sample-apps/SpringBoot2.7Postgres/src/main/java/com/example/demo Expand file tree Collapse file tree 1 file changed +10
-1
lines changed Original file line number Diff line number Diff line change 1
1
package com .example .demo ;
2
2
3
+ import dev .aikido .agent_api .SetUser ;
3
4
import org .springframework .core .annotation .Order ;
4
5
import org .springframework .stereotype .Component ;
5
6
6
7
import javax .servlet .*;
8
+ import javax .servlet .http .HttpServletRequest ;
7
9
import java .io .IOException ;
8
10
11
+ import static dev .aikido .agent_api .SetUser .setUser ;
12
+
9
13
10
14
@ Component
11
15
@ Order (0 )
@@ -16,7 +20,12 @@ public void doFilter(
16
20
ServletRequest request ,
17
21
ServletResponse response ,
18
22
FilterChain chain ) throws IOException , ServletException {
19
- //setUser(new SetUser.UserObject("123", "John Doe"));
23
+ HttpServletRequest httpRequest = (HttpServletRequest ) request ;
24
+ if (httpRequest .getHeader ("user" ) != null ) {
25
+ // Useful for end2end tests:
26
+ String id = httpRequest .getHeader ("user" );
27
+ setUser (new SetUser .UserObject (id , "John Doe" ));
28
+ }
20
29
chain .doFilter (request , response );
21
30
}
22
31
}
You can’t perform that action at this time.
0 commit comments