All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.github.qq275860560.common.inteceptor.FeginInterceptor Maven / Gradle / Ivy

There is a newer version: 201905061822
Show newest version
package com.github.qq275860560.common.inteceptor;

import java.util.Enumeration;

import javax.servlet.http.HttpServletRequest;

import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;

import feign.RequestInterceptor;
import feign.RequestTemplate;

/**
 * @author [email protected]
 */
public class FeginInterceptor implements RequestInterceptor {

	@Override
	public void apply(RequestTemplate requestTemplate) {
		HttpServletRequest httpServletRequest = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes())
				.getRequest();

		Enumeration enumeration = httpServletRequest.getHeaderNames();
		while (enumeration.hasMoreElements()) {
			String key = enumeration.nextElement();
			String value = httpServletRequest.getHeader(key);
			requestTemplate.header(key, value);
		}

	}

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy