-
Notifications
You must be signed in to change notification settings - Fork 151
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
feat: add support for header based route #565
Conversation
考虑扩展下现有的samples来演示如何使用header路由 |
Good job! |
sample has been added, apache/dubbo-go-pixiu-samples#30 |
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## develop #565 +/- ##
===========================================
- Coverage 54.76% 54.66% -0.11%
===========================================
Files 669 671 +2
Lines 78297 78611 +314
===========================================
+ Hits 42882 42971 +89
- Misses 31756 31973 +217
- Partials 3659 3667 +8 ☔ View full report in Codecov by Sentry. |
@yqxu review this pr |
Kudos, SonarCloud Quality Gate passed!
|
pixiu/pkg/model/router.go
Outdated
@@ -75,22 +75,83 @@ func NewRouterMatchPrefix(name string) RouterMatch { | |||
return RouterMatch{Prefix: "/" + name + "/"} | |||
} | |||
|
|||
func (rc *RouteConfiguration) RouteByPathAndMethod(path, method string) (*RouteAction, error) { | |||
func (rc *RouteConfiguration) RouteByPathAndMethod(path, method string, header stdHttp.Header) (*RouteAction, error) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The behavior of a method should be reflected in its name. It is recommended to modify the name as RouteByPathAndMethodAndHeader.
pixiu/pkg/common/router/trie/trie.go
Outdated
@@ -317,7 +339,7 @@ func (node *Node) putPathVariable(pathVariable string, isReal bool, bizInfo inte | |||
return true | |||
} | |||
|
|||
func (node *Node) putNode(matchStr string, isReal bool, bizInfo interface{}) bool { | |||
func (node *Node) putNode(matchStr string, isReal bool, bizInfo interface{}, header map[string][]string) bool { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The "header" should be an attribute of "bizInfo".
pixiu/pkg/common/router/trie/trie.go
Outdated
@@ -333,13 +355,14 @@ func (node *Node) putNode(matchStr string, isReal bool, bizInfo interface{}) boo | |||
|
|||
if isReal { | |||
selfNode.bizInfo = bizInfo | |||
selfNode.header = header |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The "header" should be an attribute of "bizInfo".
Add support for header based route.