package com.schisandra.auth.application.interceptor;

import feign.RequestInterceptor;
import feign.RequestTemplate;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Component;
import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;

import javax.servlet.http.HttpServletRequest;
import java.util.Objects;

/**
 * @Classname FeignRequestInterceptor
 * @BelongsProject: qing-yu-club
 * @BelongsPackage: com.landaiqing.subject.application.interceptor
 * @Author: landaiqing
 * @CreateTime: 2024-03-03  21:04
 * @Description: Feign请求拦截器
 * @Version: 1.0
 */
//@Component
//public class FeignRequestInterceptor implements RequestInterceptor {
//
//    @Override
//    public void apply(RequestTemplate requestTemplate) {
//        ServletRequestAttributes requestAttributes = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes();
//        HttpServletRequest request = requestAttributes.getRequest();
//        String userId = request.getHeader("userId");
//        if (StringUtils.isNotBlank(userId)) {
//            requestTemplate.header("userId", userId);
//        }
//    }
//}
