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

Add OnError option for the http response writer #84

Merged
merged 10 commits into from
Apr 21, 2021

Conversation

joe94
Copy link
Member

@joe94 joe94 commented Apr 20, 2021

No description provided.

@joe94 joe94 linked an issue Apr 20, 2021 that may be closed by this pull request
Copy link
Contributor

@kristinapathak kristinapathak left a comment

Choose a reason for hiding this comment

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

Looks good! I like keeping two separate functions. If there's a reason we want the response function to be able to use the error, I could see just having one function. I can't think of a reason though. 👍


next.ServeHTTP(response, request.WithContext(ctx))
})
}

func (c *constructor) error(logger log.Logger, e ErrorResponseReason, auth string, err error) {
func (c *constructor) error(logger log.Logger, w http.ResponseWriter, e ErrorResponseReason, auth string, err error) {
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think we need the error function anymore with these changes? Aren't we just calling it once?


urlVal := *request.URL // copy the URL before modifying it
u, err := c.parseURL(&urlVal)
authentication, errReason, err := c.authenticationOutput(logger, request)
Copy link
Contributor

Choose a reason for hiding this comment

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

Feel free to ignore this comment.

authentication is kind of a long word for a variable; I would suggest just a or auth.

@codecov
Copy link

codecov bot commented Apr 21, 2021

Codecov Report

Merging #84 (668dba8) into main (c3f9314) will increase coverage by 0.23%.
The diff coverage is 100.00%.

❗ Current head 668dba8 differs from pull request most recent head a73ff22. Consider uploading reports for the commit a73ff22 to get more accurate results
Impacted file tree graph

@@            Coverage Diff             @@
##             main      #84      +/-   ##
==========================================
+ Coverage   67.78%   68.02%   +0.23%     
==========================================
  Files          26       27       +1     
  Lines         683      688       +5     
==========================================
+ Hits          463      468       +5     
  Misses        201      201              
  Partials       19       19              
Impacted Files Coverage Δ
basculehttp/constructor.go 100.00% <100.00%> (ø)
basculehttp/errorResponseReason.go 100.00% <100.00%> (ø)

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 c3f9314...a73ff22. Read the comment docs.

@joe94 joe94 marked this pull request as ready for review April 21, 2021 19:32
Copy link
Contributor

@kristinapathak kristinapathak left a comment

Choose a reason for hiding this comment

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

🎉

@joe94 joe94 merged commit ea3e908 into main Apr 21, 2021
@joe94 joe94 deleted the feature/constructorOption branch April 21, 2021 21:14
@sonarcloud
Copy link

sonarcloud bot commented Apr 21, 2021

Kudos, SonarCloud Quality Gate passed!

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

100.0% 100.0% Coverage
0.0% 0.0% Duplication

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.

OnError option for the Constructor with access to the http.ResponseWriter
2 participants