Apply tower layer/middleware only on one service #1200
-
| 
         Hello, I have 2 services, one for the reflection, and one for my main service Server::builder()
  .layer(my_auth_middleware)
  .add_service(reflection_service) // <-- I would like not apply auth middleware for this service
  .add_service(my_service)
 Thanks for the help!  | 
  
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 1 reply
-
| 
         I would check the incoming path of the http request and match on that. Each service provides a https://docs.rs/tonic/latest/tonic/server/trait.NamedService.html trait impl that you can use to match only on that one inbound services requests.  | 
  
Beta Was this translation helpful? Give feedback.
-
| 
         @harscoet this is small wrapper around tonic middleware which does exactly what you need https://github.com/teimuraz/tonic-middleware  | 
  
Beta Was this translation helpful? Give feedback.
-
| 
         @harscoet I know this is old, but a perhaps slightly more elegant solution I found is that you can do the following  | 
  
Beta Was this translation helpful? Give feedback.
I would check the incoming path of the http request and match on that. Each service provides a https://docs.rs/tonic/latest/tonic/server/trait.NamedService.html trait impl that you can use to match only on that one inbound services requests.