Comments (7)
https://golang.org/pkg/net/http/#Request.FormValue
from ansible-service-broker.
-1 query parameters are not forms. The POSTs we are getting are "application/json" with query parameters on the url. The FormValue code looks for "multipart/form-data" or "application/x-www-form-urlencoded". If this was a traditional form post FormValue is the way to go. But with the JSON coming in, we're good.
from ansible-service-broker.
I disagree
FormValue returns the first value for the named component of the query. POST and PUT body parameters take precedence over URL query string values.
FormValue returns the URL Query String parameters and yes will be overridden only if there is a form body with that key. To your point that we will not be sending a form and therefore do not have to worry about the query string being overridden. IMO this is a cleaner way of retrieving url� query parameters.
from ansible-service-broker.
I did some experimenting, the FormValue
seems to do what we expect but it definitely is counter-intuitive to me.
It returned the value I expected for both POST
and GET
[2017-07-25T09:47:32.27-04:00] [INFO] Request: "POST /v2/foo?accepts_incomplete=true HTTP/2.0\r\nHost: localhost:1338\r\nAccept: */*\r\nContent-Length: 245\r\nContent-Type: application/json\r\nUser-Agent: curl/7.53.1\r\nX-Broker-Api-Version: 2.9\r\n\r\n{\n \"plan_id\": \"4c10ff42-be89-420a-9bab-27a9bef9aed8\",\n \"service_id\": \"0aaafc10-132b-41a8-a58c-73268ff1006a\",\n \"context\": {\n \"platform\": \"kubernetes\",\n \"namespace\": \"mysql-project\"\n }\n \"parameters\": {\n \"MYSQL_USER\": \"username\"\n }\n}"
form: map[]
postform: map[]
formvalue returns: true
async is: true
[2017-07-25T09:51:49.042-04:00] [INFO] Request: "GET /v2/foo?accepts_incomplete=true HTTP/2.0\r\nHost: localhost:1338\r\nAccept: */*\r\nContent-Length: 245\r\nContent-Type: application/json\r\nUser-Agent: curl/7.53.1\r\nX-Broker-Api-Version: 2.9\r\n\r\n{\n \"plan_id\": \"4c10ff42-be89-420a-9bab-27a9bef9aed8\",\n \"service_id\": \"0aaafc10-132b-41a8-a58c-73268ff1006a\",\n \"context\": {\n \"platform\": \"kubernetes\",\n \"namespace\": \"mysql-project\"\n }\n \"parameters\": {\n \"MYSQL_USER\": \"username\"\n }\n}"
form: map[]
postform: map[]
formvalue returns: true
async is: true
Okay so I stand corrected.
from ansible-service-broker.
It is kind of a weird name for that method.
from ansible-service-broker.
For other HTTP methods, or when the Content-Type is not application/x-www-form-urlencoded, the request Body is not read, and r.PostForm is initialized to a non-nil, empty value.
The above had me worried because our Content-Type is application/json
. But it seems to be smart enough to get what it needs. Even for a GET. Again for GETs it seems counter-intuitive to look ask a "form" for the query param values.
from ansible-service-broker.
Old, but part of why using FormValue and ParseForm worried me for POSTs with JSON.
https://nathanleclaire.com/blog/2013/11/30/fear-and-loathing-with-golang-and-angular-js/
from ansible-service-broker.
Related Issues (20)
- automation-broker-apb canary image hangs running tests sometimes HOT 13
- Loop in provisioning objects HOT 3
- k8s installation script does not longer exists HOT 7
- Helm registry adapter HTTP basic authentication HOT 7
- Unable to load secret on ASB HOT 4
- Future Release Branches Frozen For Merging | branch:release-4.5 branch:release-4.4
- No serviceInstance of Postgresql APB is created when running on kube 1.14 HOT 3
- apb/install.yaml does not exist anymore HOT 14
- Add possibility to declare secrets within the localregistry temporary projects. HOT 5
- Cannot install ansible-service-broker on kubernetes HOT 5
- Future Release Branches Frozen For Merging | branch:release-4.6 branch:release-4.5
- Broker fails to discover HELM charts if absolute URL is not present in index.yaml HOT 3
- Future Release Branches Frozen For Merging | branch:release-4.7 branch:release-4.6 HOT 2
- The service broker returned an invalid response for the request to https://broker.automation-broker.svc:1338/ansible-service-broker//v2/catalog HOT 2
- Broker reports : Unable to load secret 'afe58628-6998-444a-9ce4-584bec842e22' from namespace 'automation-broker' HOT 3
- Could not find instance 425596b8-7d39-4f94-b501-7b676491f203 associated with job state HOT 12
- Errors you may encounter when upgrading the library HOT 7
- Future Release Branches Frozen For Merging | branch:release-4.10 branch:release-4.9 HOT 4
- Status of this project? HOT 4
- Future Release Branches Frozen For Merging | branch:release-4.18 branch:release-4.19
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ansible-service-broker.