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

feat: add support for header based route #565

Merged
merged 7 commits into from
Jul 2, 2023

Conversation

shawnh2
Copy link
Contributor

@shawnh2 shawnh2 commented Jun 4, 2023

Add support for header based route.

  • when use it alone in a route, it has the higher priority to be matched in a router

@ma642 ma642 requested review from ma642 and mark4z June 4, 2023 12:17
pixiu/pkg/common/router/router.go Show resolved Hide resolved
@mark4z
Copy link
Member

mark4z commented Jun 11, 2023

考虑扩展下现有的samples来演示如何使用header路由

@mark4z
Copy link
Member

mark4z commented Jun 11, 2023

Good job!

@shawnh2
Copy link
Contributor Author

shawnh2 commented Jun 16, 2023

考虑扩展下现有的samples来演示如何使用header路由

sample has been added, apache/dubbo-go-pixiu-samples#30

@codecov-commenter
Copy link

codecov-commenter commented Jun 17, 2023

Codecov Report

Attention: Patch coverage is 69.56522% with 7 lines in your changes missing coverage. Please review.

Project coverage is 54.66%. Comparing base (613998a) to head (97105fd).
Report is 33 commits behind head on develop.

Files with missing lines Patch % Lines
pixiu/pkg/common/router/router.go 69.56% 4 Missing and 3 partials ⚠️
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.
📢 Have feedback on the report? Share it here.

@AlexStocks
Copy link
Contributor

@yqxu review this pr

@sonarqubecloud
Copy link

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 1 Code Smell

No Coverage information No Coverage information
1.7% 1.7% Duplication

@@ -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) {
Copy link
Contributor

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.

@@ -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 {
Copy link
Contributor

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".

@@ -333,13 +355,14 @@ func (node *Node) putNode(matchStr string, isReal bool, bizInfo interface{}) boo

if isReal {
selfNode.bizInfo = bizInfo
selfNode.header = header
Copy link
Contributor

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".

@AlexStocks AlexStocks merged commit f498fe5 into apache:develop Jul 2, 2023
@mark4z mark4z added this to the v1.0.0 milestone Aug 27, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants