У меня есть контроллер покоя, и я хочу предоставить средства для доступа к бину "Session", который я создаю, извлекая информацию из заголовка http.
По этой причине я создал HttpInterceptor, который предварительно обрабатывает запрос путем извлечения заголовков:
@Override
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler)
throws Exception {
String remoteUser = request.getHeader("x-remote-user");
log.info("Helo {}", remoteUser);
MySession session = new MySession();
session.setUser(remoteUser);
//what now?
return true;
}
Но как я могу сделать что-то вроде этого:
public MyController {
public ResponseEntitity<String> action(Request a){
MySession user = getUserSession(); //here I should be able to retrieve the session for that specific user
}
}