org.springframework.network.NetworkResolverHandlerInterceptor Maven / Gradle / Ivy
package org.springframework.network;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.springframework.web.servlet.handler.HandlerInterceptorAdapter;
public class NetworkResolverHandlerInterceptor extends HandlerInterceptorAdapter {
private final NetworkResolver networkResolver;
public NetworkResolverHandlerInterceptor() {
this(new LiteNetworkResolver());
}
public NetworkResolverHandlerInterceptor(NetworkResolver networkResolver) {
this.networkResolver = networkResolver;
}
@Override
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
Network network = networkResolver.resolveNetwork(request);
request.setAttribute(NetworkUtils.CURRENT_NETWORK_ATTRIBUTE, network);
return true;
}
}