Skip to content

How to handle context of a processing. #1600

@dulm

Description

@dulm

I need to sign the content of body, then add to head.
The signKey is different for each different user.
So i need to pass signKey to SignRequestInterceptor, the signKey is context.
there is context concept in WebClient, can be retrive in any part of the procedue.

q1:
In feign, is there any official way to save the context?

q2:
We could use header as the context, but the defaultRequestHeaders is added as interceptor after the requestInterceptors.
so we can't get the head in requestInterceptors.

Can feign fix it, change the order?

        defaultRequestHeaders:
          APP_ID: 123
          APP_KEY: abc
        requestInterceptors:
          - club.AuthRequestInterceptor

FeignClientFactoryBean.configureUsingProperties:

		if (config.getRequestInterceptors() != null && !config.getRequestInterceptors().isEmpty()) {
			// this will add request interceptor to builder, not replace existing
			for (Class<RequestInterceptor> bean : config.getRequestInterceptors()) {
				RequestInterceptor interceptor = getOrInstantiate(bean);
				builder.requestInterceptor(interceptor);
			}
		}
                ....
               /
		addDefaultRequestHeaders(config, builder);

Metadata

Metadata

Assignees

No one assigned

    Labels

    feedback providedFeedback has been provided to the authorquestionGeneral usage or 'how-to' questions

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions