org.springframework.network.NetworkResolverRequestFilter Maven / Gradle / Ivy
package org.springframework.network;
import java.io.IOException;
import javax.servlet.FilterChain;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.springframework.web.filter.OncePerRequestFilter;
public class NetworkResolverRequestFilter extends OncePerRequestFilter {
private final NetworkResolver networkResolver;
public NetworkResolverRequestFilter() {
this(new LiteNetworkResolver());
}
public NetworkResolverRequestFilter(NetworkResolver networkResolver) {
this.networkResolver = networkResolver;
}
@Override
protected void doFilterInternal(HttpServletRequest request, HttpServletResponse response, FilterChain filterChain) throws ServletException, IOException {
Network network = networkResolver.resolveNetwork(request);
request.setAttribute(NetworkUtils.CURRENT_NETWORK_ATTRIBUTE, network);
filterChain.doFilter(request, response);
}
}