mirror of
https://github.com/gin-gonic/gin.git
synced 2025-10-16 21:32:11 +08:00
Adjusted naming and formatting
This commit is contained in:
parent
100d5889b6
commit
961f4951f4
@ -383,13 +383,13 @@ func (c *Context) Param(key string) string {
|
|||||||
return c.Params.ByName(key)
|
return c.Params.ByName(key)
|
||||||
}
|
}
|
||||||
|
|
||||||
// SetParam adds param to context an
|
// AddParam adds param to context an
|
||||||
// replaces path param key with given value for e2e testing purposes
|
// replaces path param key with given value for e2e testing purposes
|
||||||
// Example Route: "/user/:id"
|
// Example Route: "/user/:id"
|
||||||
// SetParam("id", 1)
|
// AddParam("id", 1)
|
||||||
// Result: "/user/1"
|
// Result: "/user/1"
|
||||||
func (c *Context) SetParam(key, value string) {
|
func (c *Context) AddParam(key, value string) {
|
||||||
c.Params = append(c.Params, Param{Key: key,Value: value})
|
c.Params = append(c.Params, Param{Key: key, Value: value})
|
||||||
}
|
}
|
||||||
|
|
||||||
// Query returns the keyed url query value if it exists,
|
// Query returns the keyed url query value if it exists,
|
||||||
|
@ -2151,11 +2151,11 @@ func TestContextWithFallbackValueFromRequestContext(t *testing.T) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestContextSetParam(t *testing.T) {
|
func TestContextAddParam(t *testing.T) {
|
||||||
c := &Context{}
|
c := &Context{}
|
||||||
id := "id"
|
id := "id"
|
||||||
value := "1"
|
value := "1"
|
||||||
c.SetParam(id, value)
|
c.AddParam(id, value)
|
||||||
|
|
||||||
v, ok := c.Params.Get(id)
|
v, ok := c.Params.Get(id)
|
||||||
assert.Equal(t, ok, true)
|
assert.Equal(t, ok, true)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user