
package com.pavis.admin.schedule.config;

import feign.RequestInterceptor;
import feign.RequestTemplate;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;
import com.pavis.admin.schedule.api.JobClient;
import com.pavis.admin.schedule.constant.JobConstants;

/**
 * Feign 请求拦截器
 *
 *
 * @since 2025/3/28 21:17
 */
@Component
@RequiredArgsConstructor
public class FeignRequestInterceptor implements RequestInterceptor {

    private final JobClient jobClient;

    @Value("${snail-job.namespace}")
    private String namespace;

    @Override
    public void apply(RequestTemplate requestTemplate) {
        requestTemplate.header(JobConstants.NAMESPACE_ID_HEADER, namespace);
        requestTemplate.header(JobConstants.AUTH_TOKEN_HEADER, jobClient.getToken());
    }
}