Skip to content

Fix node's parameter names assignment problem #1201

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

Merged
merged 1 commit into from
Oct 7, 2018

Conversation

phelrine
Copy link
Contributor

@phelrine phelrine commented Oct 4, 2018

This commit fixed the issues(#1052, #1139) on which the parameters cannot be obtained on some paths defined as having the same prefix but with different parameter names.
This issue is caused because the node.pnames of shorter paths is overwritten by the node of longer paths inserted.
With this change, I managed to apply the changes to the pnames of a specific node only when the appending node corresponds to the end of URL's path.

I added the following test cases (#1052 and #1139). We have confirmed that the behavior is as expected.
However, this commit does not fix the case (#1139) found below because it needs to store ppath and pnames for each HTTP method like a methodHandler.

func main() {
    e := echo.New()
    e.GET("/order/:shopid", func(c echo.Context) error {
        return c.NoContent(http.StatusOK)
    })
    e.DELETE("/order/:ref", func(c echo.Context) error {
        log.Printf("params %v", c.ParamNames())
        foo := c.Param("ref")
        return c.String(http.StatusOK, foo)
    })
    e.Logger.Fatal(e.Start("127.0.0.1:8080"))
}

@phelrine phelrine force-pushed the fix-pname-assignment-problem branch from fb0373d to 7b4be99 Compare October 4, 2018 02:50
@codecov
Copy link

codecov bot commented Oct 4, 2018

Codecov Report

Merging #1201 into master will not change coverage.
The diff coverage is 100%.

Impacted file tree graph

@@           Coverage Diff           @@
##           master    #1201   +/-   ##
=======================================
  Coverage   81.51%   81.51%           
=======================================
  Files          25       25           
  Lines        1920     1920           
=======================================
  Hits         1565     1565           
  Misses        248      248           
  Partials      107      107
Impacted Files Coverage Δ
router.go 93.3% <100%> (ø) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 036e696...7b4be99. Read the comment docs.

@vishr vishr merged commit af5c977 into labstack:master Oct 7, 2018
@vishr vishr self-requested a review October 7, 2018 03:04
@vishr
Copy link
Member

vishr commented Oct 7, 2018

@phelrine thanks for your contribution

@dovys dovys mentioned this pull request Nov 1, 2018
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.

2 participants