-
Notifications
You must be signed in to change notification settings - Fork 564
Issue #177 malformed urls inside json response #178
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
Conversation
Codecov Report
@@ Coverage Diff @@
## master #178 +/- ##
==========================================
+ Coverage 77.2% 77.38% +0.18%
==========================================
Files 18 18
Lines 636 650 +14
==========================================
+ Hits 491 503 +12
- Misses 104 105 +1
- Partials 41 42 +1
Continue to review full report at Codecov.
|
// SetResponseNonEscapeHTML will NOT coerced JSON strings to valid UTF-8, | ||
// The angle brackets "<" and ">" will NOT be escaped to "\u003c" and "\u003e" | ||
// Ampersand "&" is also NOT be escaped to "\u0026". | ||
func SetResponseNonEscapeHTML(flag bool) { |
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.
Instead of a package global setter, I'd prefer optional values to somehow be configured on the type returned by NewHandler
. I think this could be done in a backwards compatible way in one of these two approaches:
- adding a
HandlerOptions
type to pass as varargs toNewHandler
. eg:
NewHandler(handler interface{}, opts... HandlerOptions) lambda.Handler
.
- update NewHandler to return a new struct
*JSONHandler
still implementinglambda.Handler
, and add this add this configuration as a method for that struct. eg:
func NewHandler(handler interface{}) *JSONHandler
func (handler *JSONHandler) SetEscapeHTML(on bool)
I think I like option 2 better, since it would setup a pattern for mirroring the other json encode/decode options like https://golang.org/pkg/encoding/json/#Encoder.SetEscapeHTML
In-use, this'd look like
func main() {
jsonHandler := NewHandler(func () (string, error) {
return "<html><body>html in json string!</body></html>", nil
});
jsonHandler.SetEscapeHTML(false);
lambda.StartHandler(jsonHandler)
}
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.
Didnt have to much time lately, took a look at again, do you mean the Handler interface can be modified like ex: https://github.com/skiarn/aws-lambda-go/tree/aws-lambda-encoder Maybe only having For me the work around proposed in #177, is good enough for me, I have the ability to implement desired serializers. Maybe instead of having more methods on the Handler interface documentation may be better? highlighting how invoke can be used when serializing req and resp? func main() { |
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.