zeromicro / go-zero

A cloud-native Go microservices framework with cli tool for productivity.
https://go-zero.dev
MIT License
28.41k stars 3.87k forks source link

Can add a middleware that supports single routing #3548

Open xjl12322 opened 10 months ago

xjl12322 commented 10 months ago

So I need to split multiple routing groups. I just want to specify an interface under the same routing group that requires jwt verification. Other interfaces do not need to For example in the following example, I need the add, getById method jwt check。No other method is needed @server( prefix: book/v1 group: book ) service book-api{ jwt: JwtAuth @handler add post /add (AddBookReq) returns (AddBookResp) jwt: JwtAuth @handler getById get /get(GetBookByIdReq) returns (GetBookByIdResp) @handler getByIdList post /getIdList(GetBookByIdListReq) returns (GetBookByIdListResp)` }

kevwan commented 10 months ago

Sure, you can separate the jwt related routes from others in API file.