Skip to content

io microsphere spring cloud openfeign components CompositedRequestInterceptor

github-actions[bot] edited this page Jun 10, 2026 · 6 revisions

CompositedRequestInterceptor

Type: Class | Module: microsphere-spring-cloud-openfeign | Package: io.microsphere.spring.cloud.openfeign.components | Since: 0.0.1

Source: microsphere-spring-cloud-openfeign/src/main/java/io/microsphere/spring/cloud/openfeign/components/CompositedRequestInterceptor.java

Overview

CompositedRequestInterceptor is a class in the io.microsphere.spring.cloud.openfeign.components package of the microsphere-spring-cloud-openfeign module.

Declaration

public class CompositedRequestInterceptor implements RequestInterceptor, Refreshable

Author: 韩超

Version Information

  • Introduced in: 0.0.1
  • Current Project Version: 0.2.18-SNAPSHOT

Version Compatibility

This component is tested and compatible with the following Java versions:

Java Version Status
Java 17 ✅ Compatible
Java 21 ✅ Compatible
Java 25 ✅ Compatible

Examples

Method Examples

getRequestInterceptors

CompositedRequestInterceptor interceptor =
    new CompositedRequestInterceptor("my-client", beanFactory);
Set<RequestInterceptor> interceptors = compositedInterceptor.getRequestInterceptors();

apply

RequestTemplate template = new RequestTemplate();
compositedInterceptor.apply(template);

addRequestInterceptor

boolean wasFirst = compositedInterceptor.addRequestInterceptor(
    template -> template.header("Authorization", "Bearer token"));

refresh

compositedInterceptor.refresh();

Usage

Maven Dependency

Add the following dependency to your pom.xml:

<dependency>
    <groupId>io.github.microsphere-projects</groupId>
    <artifactId>microsphere-spring-cloud-openfeign</artifactId>
    <version>${microsphere-spring-cloud.version}</version>
</dependency>

Tip: Use the BOM (microsphere-spring-cloud-dependencies) for consistent version management. See the Getting Started guide.

Import

import io.microsphere.spring.cloud.openfeign.components.CompositedRequestInterceptor;

API Reference

Public Methods

Method Description
getRequestInterceptors Constructs a CompositedRequestInterceptor for the specified Feign client context.
apply Applies all registered RequestInterceptor instances to the given
addRequestInterceptor Adds a RequestInterceptor to this composite. Returns true if this
refresh Refreshes the set of RequestInterceptor instances by re-reading the

Method Details

getRequestInterceptors

public Set<RequestInterceptor> getRequestInterceptors()

Constructs a CompositedRequestInterceptor for the specified Feign client context.

Example Usage:

`CompositedRequestInterceptor interceptor =
    new CompositedRequestInterceptor("my-client", beanFactory);
`

apply

public void apply(RequestTemplate template)

Applies all registered RequestInterceptor instances to the given RequestTemplate in order.

Example Usage:

`RequestTemplate template = new RequestTemplate();
compositedInterceptor.apply(template);
`

addRequestInterceptor

public boolean addRequestInterceptor(RequestInterceptor requestInterceptor)

Adds a RequestInterceptor to this composite. Returns true if this is the first interceptor added (i.e., the composite was previously empty).

Example Usage:

`boolean wasFirst = compositedInterceptor.addRequestInterceptor(
    template -> template.header("Authorization", "Bearer token"));
`

refresh

public void refresh()

Refreshes the set of RequestInterceptor instances by re-reading the FeignClientProperties configuration for request interceptors, default headers, and default query parameters.

Example Usage:

`compositedInterceptor.refresh();
`

This documentation was auto-generated from the source code of microsphere-spring-cloud.

Home

spring-cloud-commons

spring-cloud-openfeign

Clone this wiki locally