diff --git a/option.go b/option.go index 0c9bc911..83d0a8d9 100644 --- a/option.go +++ b/option.go @@ -12,50 +12,50 @@ func Use(middleware ...HandlerFunc) OptionFunc { } } -// Get is a shortcut for RouterGroup.Handle("GET", path, handle) -func Get(path string, handlers ...HandlerFunc) OptionFunc { +// GET is a shortcut for RouterGroup.Handle("GET", path, handle) +func GET(path string, handlers ...HandlerFunc) OptionFunc { return func(e *Engine) { e.GET(path, handlers...) } } -// Post is a shortcut for RouterGroup.Handle("POST", path, handle) -func Post(path string, handlers ...HandlerFunc) OptionFunc { +// POST is a shortcut for RouterGroup.Handle("POST", path, handle) +func POST(path string, handlers ...HandlerFunc) OptionFunc { return func(e *Engine) { e.POST(path, handlers...) } } -// Put is a shortcut for RouterGroup.Handle("PUT", path, handle) -func Put(path string, handlers ...HandlerFunc) OptionFunc { +// PUT is a shortcut for RouterGroup.Handle("PUT", path, handle) +func PUT(path string, handlers ...HandlerFunc) OptionFunc { return func(e *Engine) { e.PUT(path, handlers...) } } -// Delete is a shortcut for RouterGroup.Handle("DELETE", path, handle) -func Delete(path string, handlers ...HandlerFunc) OptionFunc { +// DELETE is a shortcut for RouterGroup.Handle("DELETE", path, handle) +func DELETE(path string, handlers ...HandlerFunc) OptionFunc { return func(e *Engine) { e.DELETE(path, handlers...) } } -// Patch is a shortcut for RouterGroup.Handle("PATCH", path, handle) -func Patch(path string, handlers ...HandlerFunc) OptionFunc { +// PATCH is a shortcut for RouterGroup.Handle("PATCH", path, handle) +func PATCH(path string, handlers ...HandlerFunc) OptionFunc { return func(e *Engine) { e.PATCH(path, handlers...) } } -// Head is a shortcut for RouterGroup.Handle("HEAD", path, handle) -func Head(path string, handlers ...HandlerFunc) OptionFunc { +// HEAD is a shortcut for RouterGroup.Handle("HEAD", path, handle) +func HEAD(path string, handlers ...HandlerFunc) OptionFunc { return func(e *Engine) { e.HEAD(path, handlers...) } } -// Options is a shortcut for RouterGroup.Handle("OPTIONS", path, handle) -func Options(path string, handlers ...HandlerFunc) OptionFunc { +// OPTIONS is a shortcut for RouterGroup.Handle("OPTIONS", path, handle) +func OPTIONS(path string, handlers ...HandlerFunc) OptionFunc { return func(e *Engine) { e.OPTIONS(path, handlers...) } diff --git a/option_test.go b/option_test.go index 574a148d..2205ac1b 100644 --- a/option_test.go +++ b/option_test.go @@ -30,7 +30,7 @@ func TestOption_HttpMethod(t *testing.T) { { method: http.MethodGet, path: "/get", - optionFunc: Get("/get", func(c *Context) { + optionFunc: GET("/get", func(c *Context) { assert.Equal(t, http.MethodGet, c.Request.Method) assert.Equal(t, "/get", c.Request.URL.Path) }), @@ -38,7 +38,7 @@ func TestOption_HttpMethod(t *testing.T) { { method: http.MethodPut, path: "/put", - optionFunc: Put("/put", func(c *Context) { + optionFunc: PUT("/put", func(c *Context) { assert.Equal(t, http.MethodPut, c.Request.Method) assert.Equal(t, "/put", c.Request.URL.Path) }), @@ -46,7 +46,7 @@ func TestOption_HttpMethod(t *testing.T) { { method: http.MethodPost, path: "/post", - optionFunc: Post("/post", func(c *Context) { + optionFunc: POST("/post", func(c *Context) { assert.Equal(t, http.MethodPost, c.Request.Method) assert.Equal(t, "/post", c.Request.URL.Path) }), @@ -54,7 +54,7 @@ func TestOption_HttpMethod(t *testing.T) { { method: http.MethodDelete, path: "/delete", - optionFunc: Delete("/delete", func(c *Context) { + optionFunc: DELETE("/delete", func(c *Context) { assert.Equal(t, http.MethodDelete, c.Request.Method) assert.Equal(t, "/delete", c.Request.URL.Path) }), @@ -62,7 +62,7 @@ func TestOption_HttpMethod(t *testing.T) { { method: http.MethodPatch, path: "/patch", - optionFunc: Patch("/patch", func(c *Context) { + optionFunc: PATCH("/patch", func(c *Context) { assert.Equal(t, http.MethodPatch, c.Request.Method) assert.Equal(t, "/patch", c.Request.URL.Path) }), @@ -70,7 +70,7 @@ func TestOption_HttpMethod(t *testing.T) { { method: http.MethodOptions, path: "/options", - optionFunc: Options("/options", func(c *Context) { + optionFunc: OPTIONS("/options", func(c *Context) { assert.Equal(t, http.MethodOptions, c.Request.Method) assert.Equal(t, "/options", c.Request.URL.Path) }), @@ -78,7 +78,7 @@ func TestOption_HttpMethod(t *testing.T) { { method: http.MethodHead, path: "/head", - optionFunc: Head("/head", func(c *Context) { + optionFunc: HEAD("/head", func(c *Context) { assert.Equal(t, http.MethodHead, c.Request.Method) assert.Equal(t, "/head", c.Request.URL.Path) }),