-
Notifications
You must be signed in to change notification settings - Fork 6
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
Extend content negotiation functionality #47
Conversation
Codecov Report
@@ Coverage Diff @@
## master #47 +/- ##
=======================================
Coverage 46.61% 46.61%
=======================================
Files 15 15
Lines 3152 3152
=======================================
Hits 1469 1469
Misses 1521 1521
Partials 162 162
Continue to review full report at Codecov.
|
wrphttp/requestResponse.go
Outdated
encoder = wrp.NewEncoderBytes(&output, erw.f) | ||
) | ||
func (erw *entityResponseWriter) WriteWRP(e *Entity) (int, error) { | ||
if e == nil { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Generally, you don't need to do this. It's ok to allow panics on nil. That indicates a bug in the calling code, which you don't want to mask with a "normal" call return.
wrphttp/requestResponse.go
Outdated
} | ||
|
||
erw.ResponseWriter.Header().Set("Content-Type", erw.f.ContentType()) | ||
return erw.ResponseWriter.Write(output) | ||
} | ||
|
||
func (erw *entityResponseWriter) WriteWRPFromBytes(f wrp.Format, encodedWRP []byte) (int, error) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As a general naming convention, words like "from" are avoided in golang
APIs. This can be just WriteWRPBytes
.
This PR adds convenience functions for a WRP handler's content negotiation strategy.