mirror of
https://github.com/gin-gonic/gin.git
synced 2026-06-07 04:38:19 +08:00
Merge 28c82b274efd596f9680d66b734ae759ad7659f1 into d5b353c5d5a560322e6d96121c814115562501f7
This commit is contained in:
commit
66d1cea905
@ -83,6 +83,11 @@ func (c *Context) HandlerName() string {
|
|||||||
return nameOfFunction(c.handlers.Last())
|
return nameOfFunction(c.handlers.Last())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Handler returns the main handler.
|
||||||
|
func (c *Context) Handler() HandlerFunc {
|
||||||
|
return c.handlers.Last()
|
||||||
|
}
|
||||||
|
|
||||||
/************************************/
|
/************************************/
|
||||||
/*********** FLOW CONTROL ***********/
|
/*********** FLOW CONTROL ***********/
|
||||||
/************************************/
|
/************************************/
|
||||||
|
|||||||
@ -161,6 +161,13 @@ func handlerNameTest(c *Context) {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestContextHandler(t *testing.T) {
|
||||||
|
c, _, _ := CreateTestContext()
|
||||||
|
c.handlers = HandlersChain{func(c *Context) {}, handlerNameTest}
|
||||||
|
|
||||||
|
assert.Equal(t, handlerNameTest, c.Handler())
|
||||||
|
}
|
||||||
|
|
||||||
func TestContextQuery(t *testing.T) {
|
func TestContextQuery(t *testing.T) {
|
||||||
c, _, _ := CreateTestContext()
|
c, _, _ := CreateTestContext()
|
||||||
c.Request, _ = http.NewRequest("GET", "http://example.com/?foo=bar&page=10&id=", nil)
|
c.Request, _ = http.NewRequest("GET", "http://example.com/?foo=bar&page=10&id=", nil)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user