Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

middleware/selector: 支持更丰富的中间件匹配功能 #1241

Closed
tonybase opened this issue Jul 25, 2021 · 8 comments
Closed

middleware/selector: 支持更丰富的中间件匹配功能 #1241

tonybase opened this issue Jul 25, 2021 · 8 comments
Labels
Milestone

Comments

@tonybase
Copy link
Member

tonybase commented Jul 25, 2021

通过middleware支持特定路由匹配:

http.Middleware(
    selector.Client(logging.Server(), authjwt.Server())
        .Prefix("/helloworld.")
        .Regex("/helloworld.{Say*}"),
        .Path("/helloworld.SayHello"),
)

http.Middleware(
    selector.Server(logging.Server(), authjwt.Server())
        .Prefix("/helloworld.")
        .Regex("/helloworld.{Say*}"),
        .Path("/helloworld.SayHello"),
)

匹配模式:

builder.Prefix("/helloworld.")
builder.Regex("/helloworld.{Say*}")
builder.Path("/helloworld.method")

反正声明:

builder.NotPrefix("/helloworld.")
builder.NotRegex("/helloworld.{Say*}")
builder.NotPath("/helloworld.SayHello")
@shenqidebaozi
Copy link
Sponsor Member

如果可以的话,第一个参数是否可以传入数组类型?因为有可能某些路由的中间件配置相同,但是通过前缀,正则可能不太好匹配到一起去。

@pigfall
Copy link
Contributor

pigfall commented Jan 14, 2022

真滴棒 ❤️

@shanezhiu
Copy link

翻看源码并没有实现NotPrefix, NotRegex, NotPath

@kratos-ci-bot
Copy link
Collaborator

Bot detected the issue body's language is not English, translate it automatically. 👯👭🏻🧑‍🤝‍🧑👫🧑🏿‍🤝‍🧑🏻👩🏾‍🤝‍👨🏿👬🏿


Looking at the source code does not implement NotPrefix, NotRegex, NotPath

@shenqidebaozi
Copy link
Sponsor Member

Bot detected the issue body's language is not English, translate it automatically. 👯👭🏻🧑‍🤝‍🧑👫🧑🏿‍🤝‍🧑🏻👩🏾‍🤝‍👨🏿👬🏿

Looking at the source code does not implement NotPrefix, NotRegex, NotPath
@shanezhiu
simply use the custom method mode

@shanezhiu
Copy link

Bot detected the issue body's language is not English, translate it automatically. 👯👭🏻🧑‍🤝‍🧑👫🧑🏿‍🤝‍🧑🏻👩🏾‍🤝‍👨🏿👬🏿

Looking at the source code does not implement NotPrefix, NotRegex, NotPath
@shanezhiu
simply use the custom method mode

I can not get you. Do you mean that I can do this with a self defined Match method?

@shanezhiu
Copy link

thanks a lot

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

5 participants