1
0
mirror of https://github.com/astaxie/beego.git synced 2025-07-04 09:40:19 +00:00

Fix Context.Input.SetParam not overwriting existing value

- Also added tests for Context.Input.Param handling
This commit is contained in:
Pelle Johnsen
2016-01-27 14:58:50 +01:00
parent 4ce094a29a
commit 453d744db9
2 changed files with 61 additions and 0 deletions

View File

@ -287,6 +287,13 @@ func (input *BeegoInput) Params() map[string]string {
// SetParam will set the param with key and value
func (input *BeegoInput) SetParam(key, val string) {
// check if already exists
for i, v := range input.pnames {
if v == key && i <= len(input.pvalues) {
input.pvalues[i] = val
return
}
}
input.pvalues = append(input.pvalues, val)
input.pnames = append(input.pnames, key)
}