spring-cloud-gateway icon indicating copy to clipboard operation
spring-cloud-gateway copied to clipboard

how to use threadlocal in spring cloud gateway

Open coldingcode opened this issue 5 years ago • 3 comments

project dependency: spring-cloud-gateway spring-boot-starter-security

I make a threadlocal instance in webfilter(webflux). but i was missing it in globalfilter(spring cloud gateway). what should i to get them to communicate

coldingcode avatar Oct 15 '21 03:10 coldingcode

threadlocal is not supported in reactor which is the basis for webflux which is what gateway is built on. ServerWebExchange has attributes that can be used https://docs.spring.io/spring-framework/docs/current/javadoc-api/org/springframework/web/server/ServerWebExchange.html#getAttributes--

You can also look at the reactor context https://projectreactor.io/docs/core/release/reference/#context

spencergibb avatar Nov 05 '21 21:11 spencergibb

If you would like us to look at this issue, please provide the requested information. If the information is not provided within the next 7 days this issue will be closed.

spring-cloud-issues avatar Nov 12 '21 21:11 spring-cloud-issues

I set the context in webfilter How can i get the context from globalfilter

coldingcode avatar Nov 18 '21 08:11 coldingcode