Merge fd86812e816290ab3bd55e7ce0be4efecc31c5b2 into 31c3b913acef43b2417d4821aab9df3a53e0baba

This commit is contained in:
Alexander Nyquist 2014-07-03 14:17:35 +00:00
commit 7bf60fdacb
2 changed files with 7 additions and 1 deletions

View File

@ -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")

5
gin.go
View File

@ -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)