Stage 5 3. Micro Services [online] studies _day18 user authorization and authentication -Feign interceptor micro service between _19-






4.2 Feign interceptor
4.2.1 Defining Feign blocker
use among micro feign remote service calls, using remote call feign interceptors carry JWT.
Add common project dependency :

<dependency>
<the groupId> org.springframework.cloud </ the groupId>
<the artifactId> Cloud-Spring-Starter-openfeign </ the artifactId>
</ dependency>



Interceptor

FeignClientInterceptor


implement the interface, the overridden method. feign each remote call will be called apply this method

to do two things

// use RequestContextHolder tool to obtain request-related variables
ServletRequestAttributes the Attributes = (ServletRequestAttributes)
RequestContextHolder.getRequestAttributes ();

Get all the headers

Where Bean is defined by where interceptors

In spring boot management courses start classes inside

Course management and cms services start.








Cycle several times before to get the authorization to go





here because of an error to request additional micro service

this is the address of another micro-services. Request additional services are required to carry micro token.


restTemplate need to think before carrying token request.




In order to quickly resolve this error. We do not verify the address to which the rule


to restart the program management services



 

Guess you like

Origin www.cnblogs.com/wangjunwei/p/11654037.html