Merge 28c82b274efd596f9680d66b734ae759ad7659f1 into d5b353c5d5a560322e6d96121c814115562501f7

This commit is contained in:
collinmsn 2017-06-02 06:44:44 +00:00 committed by GitHub
commit 66d1cea905
2 changed files with 12 additions and 0 deletions

View File

@ -83,6 +83,11 @@ func (c *Context) HandlerName() string {
return nameOfFunction(c.handlers.Last())
}
// Handler returns the main handler.
func (c *Context) Handler() HandlerFunc {
return c.handlers.Last()
}
/************************************/
/*********** FLOW CONTROL ***********/
/************************************/

View File

@ -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) {
c, _, _ := CreateTestContext()
c.Request, _ = http.NewRequest("GET", "http://example.com/?foo=bar&page=10&id=", nil)