forked from mirror/gin
Merge branch 'options' of https://github.com/alexandernyquist/gin into alexandernyquist-options
This commit is contained in:
commit
df9ba52186
|
@ -55,7 +55,7 @@ func main() {
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
#### Using GET, POST, PUT, PATCH and DELETE
|
#### Using GET, POST, PUT, PATCH, DELETE and OPTIONS
|
||||||
|
|
||||||
```go
|
```go
|
||||||
func main() {
|
func main() {
|
||||||
|
@ -67,6 +67,7 @@ func main() {
|
||||||
r.PUT("/somePut", putting)
|
r.PUT("/somePut", putting)
|
||||||
r.DELETE("/someDelete", deleting)
|
r.DELETE("/someDelete", deleting)
|
||||||
r.PATCH("/somePatch", patching)
|
r.PATCH("/somePatch", patching)
|
||||||
|
r.OPTIONS("/someOptions", options)
|
||||||
|
|
||||||
// Listen and server on 0.0.0.0:8080
|
// Listen and server on 0.0.0.0:8080
|
||||||
r.Run(":8080")
|
r.Run(":8080")
|
||||||
|
|
5
gin.go
5
gin.go
|
@ -259,6 +259,11 @@ func (group *RouterGroup) PUT(path string, handlers ...HandlerFunc) {
|
||||||
group.Handle("PUT", path, handlers)
|
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 {
|
func (group *RouterGroup) combineHandlers(handlers []HandlerFunc) []HandlerFunc {
|
||||||
s := len(group.Handlers) + len(handlers)
|
s := len(group.Handlers) + len(handlers)
|
||||||
h := make([]HandlerFunc, 0, s)
|
h := make([]HandlerFunc, 0, s)
|
||||||
|
|
Loading…
Reference in New Issue