Skip to content

JSON Parameter binding #1173

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

Merged
merged 4 commits into from
Jun 6, 2017
Merged

JSON Parameter binding #1173

merged 4 commits into from
Jun 6, 2017

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
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy