-
Notifications
You must be signed in to change notification settings - Fork 148
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 Report
@@ Coverage Diff @@
## develop #565 +/- ##
===========================================
+ Coverage 54.76% 54.79% +0.02%
===========================================
Files 669 669
Lines 78297 78331 +34
===========================================
+ Hits 42882 42918 +36
- Misses 31756 31757 +1
+ Partials 3659 3656 -3
... and 15 files with indirect coverage changes 📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more |
@yqxu review this pr |
Kudos, SonarCloud Quality Gate passed! 0 Bugs No Coverage information |
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.