Skip to content

Conversation

notzippy
Copy link
Collaborator

@notzippy notzippy commented May 7, 2017

Automatic JSON binding to struct in parameters, also changed validation to not store validation state via a cookie, since with a json request/response no redirect is required and therefor no persistent data is required.

Also renamed local variable error to err so no package conflict error will occur

@notzippy notzippy added status-tested Ready for release type-enhancement New enhancement of existing feature type-feature New feature request waffle: needs review labels May 7, 2017
@notzippy notzippy added this to the v0.16 milestone May 7, 2017
@notzippy notzippy requested a review from brendensoares May 7, 2017 19:58
@notzippy notzippy force-pushed the json-params branch 2 times, most recently from e2bf0f4 to 5cbae9e Compare May 8, 2017 04:12
notzippy added 2 commits May 19, 2017 15:52
…on to not store validation state via a cookie, since with a json request/response no redirect is required and therefor no persistent data is required.

Also renamed local variable error to err so no package conflict error will occur
params.go Outdated
@@ -31,6 +32,7 @@ type Params struct {

Files map[string][]*multipart.FileHeader // Files uploaded in a multipart form
tmpFiles []*os.File // Temp files used during the request.
Json []byte // JSON data from request body
Copy link
Member

Choose a reason for hiding this comment

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

JSON

params.go Outdated
ERROR.Println("Failed to ready request body bytes",err)
}
} else {
INFO.Println("Json post received with empty body")
Copy link
Member

Choose a reason for hiding this comment

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

JSON

}
hasCookie := (err != http.ErrNoCookie)
// If json request, we shall assume json response is intended,
// as such no validation cookies should be tied response
Copy link
Member

Choose a reason for hiding this comment

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

tied to the response

params.go Outdated
case "application/json":
fallthrough
case "text/json":
if req.Body!=nil {
Copy link
Member

Choose a reason for hiding this comment

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

WORD != WORD

keep: false,
}
hasCookie := (err != http.ErrNoCookie)
// If json request, we shall assume json response is intended,
Copy link
Member

Choose a reason for hiding this comment

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

JSON

notzippy added 2 commits May 31, 2017 17:08
Updated params so that Params.Bind() does not blindly bind json data
Added Params.BindJSON() to provide JSON bind functionality
@notzippy notzippy merged commit fa40869 into revel:develop Jun 6, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status-tested Ready for release type-enhancement New enhancement of existing feature type-feature New feature request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants