Skip to content

Replace http constants with stdlib ones #1205

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 14, 2018
Merged

Replace http constants with stdlib ones #1205

merged 1 commit into from
Oct 14, 2018

Conversation

ribice
Copy link
Contributor

@ribice ribice commented Oct 12, 2018

Resolves #1190

@@ -128,20 +128,6 @@ type (
}
)

// HTTP methods
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wouldn't it break code for users? Perhaps we can mark it deprecated and drop it in a future release.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If doubt anyone uses echo.Get instead of http.MethodGet.

Also it's quite easy to replace it if it becomes breaking change for someone.

This change simplifies the codebase by reusing constants from stdlib.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indeed it's very quick to fix, but it's used in the documentation; https://echo.labstack.com/middleware/cors.
I used those constants, rather than the stdlib ones, because of the docs. I know it's a little late, but I can't be the only one getting broken code from this change.

Copy link
Member

@vishr vishr Oct 15, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@nipemgroup I have updated the docs to reflect this change.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I missed the fact that they are in the docs when I reviewed this, @vishr was right to bet on backward compatibility. I pushed a PR to address this: #1209 - adding the exported constants back.

I propose we 1st change the documentation, then we give proper notice, and then (maybe?) we remove them later.

@vishr
Copy link
Member

vishr commented Oct 13, 2018 via email

@alexaandru
Copy link
Contributor

I like this change, and while I value greatly backward compatibility, I also believe there is very little reason why people would use these directly. They use e.GET() & friends instead. Also, a quick search shows 0 projects using this on Github: https://github.com/search?utf8=%E2%9C%93&q=echo.Get+language%3AGo&type=Repositories&ref=advsearch&l=Go&l=

Add to that, that for production one should vendor their dependencies anyway & use tests, etc. so the chances of doing real damage with this become very small.

I would just suggest to change the commit message to give a little more info by itself, so that someone would know how to fix things if they break, from the commit message alone (though the diff itself is self explanatory):

Replace http constants with stdlib ones, i.e.: http.MethodGet instead of echo.GET, etc.

@vishr
Copy link
Member

vishr commented Oct 13, 2018

@alexaandru Sounds good, @ribice do you want to fix the commit message?

@ribice
Copy link
Contributor Author

ribice commented Oct 13, 2018

Will do tomorrow.

@ribice
Copy link
Contributor Author

ribice commented Oct 14, 2018

Done, also fixed conflicts.

@vishr
Copy link
Member

vishr commented Oct 14, 2018

@ribice Can you fix the build? Looks like cors_test.go still uses old constants.

@codecov
Copy link

codecov bot commented Oct 14, 2018

Codecov Report

Merging #1205 into master will not change coverage.
The diff coverage is 97.61%.

Impacted file tree graph

@@           Coverage Diff           @@
##           master    #1205   +/-   ##
=======================================
  Coverage   81.61%   81.61%           
=======================================
  Files          27       27           
  Lines        1931     1931           
=======================================
  Hits         1576     1576           
  Misses        248      248           
  Partials      107      107
Impacted Files Coverage Δ
middleware/proxy_1_11.go 100% <100%> (ø) ⬆️
group.go 93.75% <100%> (ø) ⬆️
router.go 93.3% <100%> (ø) ⬆️
middleware/csrf.go 76.71% <100%> (ø) ⬆️
middleware/method_override.go 84.61% <100%> (ø) ⬆️
bind.go 86.3% <100%> (ø) ⬆️
middleware/cors.go 75% <100%> (ø) ⬆️
echo.go 87.72% <90%> (ø) ⬆️

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 059c099...52bd56c. Read the comment docs.

@ribice
Copy link
Contributor Author

ribice commented Oct 14, 2018

@ribice Can you fix the build? Looks like cors_test.go still uses old constants.

Fixed.

@vishr vishr merged commit c8fd197 into labstack:master Oct 14, 2018
@ribice ribice deleted the http-constants branch October 14, 2018 15:22
vishr added a commit to labstack/echox that referenced this pull request Oct 15, 2018
Signed-off-by: Vishal Rana <vr@labstack.com>
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.

4 participants