From 5e0d560dd6e3042f0fbd51adf9fb9ab8b54ecebf Mon Sep 17 00:00:00 2001 From: Alexander Nyquist Date: Thu, 3 Jul 2014 16:14:33 +0200 Subject: [PATCH 1/2] Added support for OPTIONS verb --- gin.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/gin.go b/gin.go index 847df19c..b855ca62 100644 --- a/gin.go +++ b/gin.go @@ -207,6 +207,11 @@ func (group *RouterGroup) PUT(path string, handlers ...HandlerFunc) { group.Handle("PUT", path, handlers) } +// OPTIONS is a shortcut for router.Handle("OPTIONS", path, handle) +func (group *RouterGroup) OPTIONS(path string, handlers ...HandlerFunc) { + group.Handle("OPTIONS", path, handlers) +} + func (group *RouterGroup) combineHandlers(handlers []HandlerFunc) []HandlerFunc { s := len(group.Handlers) + len(handlers) h := make([]HandlerFunc, 0, s) From fd86812e816290ab3bd55e7ce0be4efecc31c5b2 Mon Sep 17 00:00:00 2001 From: Alexander Nyquist Date: Thu, 3 Jul 2014 16:16:40 +0200 Subject: [PATCH 2/2] Added OPTIONS to README --- README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index c2a5f117..d80f07a9 100644 --- a/README.md +++ b/README.md @@ -55,7 +55,7 @@ func main() { } ``` -#### Using GET, POST, PUT, PATCH and DELETE +#### Using GET, POST, PUT, PATCH, DELETE and OPTIONS ```go func main() { @@ -67,6 +67,7 @@ func main() { r.PUT("/somePut", putting) r.DELETE("/someDelete", deleting) r.PATCH("/somePatch", patching) + r.OPTIONS("/someOptions", options) // Listen and server on 0.0.0.0:8080 r.Run(":8080")