http/logical: Add http GET parameters to the data map (#4012)

* Add get parameters to the data object

* Add test for get params
This commit is contained in:
Brian Kassouf
2018-02-21 14:36:53 -08:00
committed by GitHub
parent b1799ecf9e
commit cfa758c80b
3 changed files with 78 additions and 7 deletions

View File

@@ -75,6 +75,30 @@ func buildLogicalRequest(core *vault.Core, w http.ResponseWriter, r *http.Reques
}
}
// If we are a read operation, try and parse any parameters
if op == logical.ReadOperation {
getData := map[string]interface{}{}
for k, v := range r.URL.Query() {
// Skip the help key as this is a reserved parameter
if k == "help" {
continue
}
switch {
case len(v) == 0:
case len(v) == 1:
getData[k] = v[0]
default:
getData[k] = v
}
}
if len(getData) > 0 {
data = getData
}
}
var err error
request_id, err := uuid.GenerateUUID()
if err != nil {