Skip to content

Use raw status codes when calling ctx.Handle #3330

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

Closed
wants to merge 1 commit into from
Closed

Use raw status codes when calling ctx.Handle #3330

wants to merge 1 commit into from

Conversation

thehowl
Copy link
Contributor

@thehowl thehowl commented Jan 8, 2018

Almost every instance of Context.Handle uses a raw HTTP status code - either 404 or 500. For consistency, I replaced the few instances where http.Status* was still used.

@codecov-io
Copy link

Codecov Report

Merging #3330 into master will decrease coverage by <.01%.
The diff coverage is 5.26%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #3330      +/-   ##
==========================================
- Coverage   35.04%   35.04%   -0.01%     
==========================================
  Files         280      280              
  Lines       40556    40556              
==========================================
- Hits        14213    14211       -2     
- Misses      24237    24239       +2     
  Partials     2106     2106
Impacted Files Coverage Δ
routers/repo/issue_watch.go 0% <0%> (ø) ⬆️
routers/repo/http.go 38.01% <0%> (ø) ⬆️
routers/repo/issue_timetrack.go 0% <0%> (ø) ⬆️
routers/repo/issue_stopwatch.go 26.66% <25%> (ø) ⬆️
models/repo_list.go 65.62% <0%> (-1.57%) ⬇️

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 f2b841d...9e6ff2f. Read the comment docs.

@tboerger tboerger added the lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. label Jan 8, 2018
@strk
Copy link
Member

strk commented Jan 8, 2018

I would actually prefer the other way around. Descriptive names are better than magic numbers IMHO

@thehowl
Copy link
Contributor Author

thehowl commented Jan 8, 2018

However, I would argue that Go is not java, and I think it's pretty tedious/verbose to write http.StatusInternalServerError and http.StatusNotFound all over the place.

Copy link
Member

@bkcsoft bkcsoft left a comment

Choose a reason for hiding this comment

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

http.Status* is the de facto Go standard. Use them

@lafriks
Copy link
Member

lafriks commented Jan 8, 2018

I would better see ctx.NotFound and ctx.InternalServerError added

@thehowl
Copy link
Contributor Author

thehowl commented Jan 8, 2018

I tend to agree with @lafriks. I'll make a PR removing ctx.Handle and replacing all instances with NotFound and InternalServerError. Closing this.

@thehowl thehowl closed this Jan 8, 2018
@thehowl thehowl mentioned this pull request Jan 9, 2018
@go-gitea go-gitea locked and limited conversation to collaborators Nov 23, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants