1
0
Fork 0
mirror of https://github.com/moby/moby.git synced 2022-11-09 12:21:53 -05:00

Merge pull request #40259 from thaJeztah/more_constants

api/server/router: use consts for HTTP methods
This commit is contained in:
Tibor Vass 2019-12-19 17:57:47 +01:00 committed by GitHub
commit a9416c67da
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -1,6 +1,8 @@
package router // import "github.com/docker/docker/api/server/router" package router // import "github.com/docker/docker/api/server/router"
import ( import (
"net/http"
"github.com/docker/docker/api/server/httputils" "github.com/docker/docker/api/server/httputils"
) )
@ -42,30 +44,30 @@ func NewRoute(method, path string, handler httputils.APIFunc, opts ...RouteWrapp
// NewGetRoute initializes a new route with the http method GET. // NewGetRoute initializes a new route with the http method GET.
func NewGetRoute(path string, handler httputils.APIFunc, opts ...RouteWrapper) Route { func NewGetRoute(path string, handler httputils.APIFunc, opts ...RouteWrapper) Route {
return NewRoute("GET", path, handler, opts...) return NewRoute(http.MethodGet, path, handler, opts...)
} }
// NewPostRoute initializes a new route with the http method POST. // NewPostRoute initializes a new route with the http method POST.
func NewPostRoute(path string, handler httputils.APIFunc, opts ...RouteWrapper) Route { func NewPostRoute(path string, handler httputils.APIFunc, opts ...RouteWrapper) Route {
return NewRoute("POST", path, handler, opts...) return NewRoute(http.MethodPost, path, handler, opts...)
} }
// NewPutRoute initializes a new route with the http method PUT. // NewPutRoute initializes a new route with the http method PUT.
func NewPutRoute(path string, handler httputils.APIFunc, opts ...RouteWrapper) Route { func NewPutRoute(path string, handler httputils.APIFunc, opts ...RouteWrapper) Route {
return NewRoute("PUT", path, handler, opts...) return NewRoute(http.MethodPut, path, handler, opts...)
} }
// NewDeleteRoute initializes a new route with the http method DELETE. // NewDeleteRoute initializes a new route with the http method DELETE.
func NewDeleteRoute(path string, handler httputils.APIFunc, opts ...RouteWrapper) Route { func NewDeleteRoute(path string, handler httputils.APIFunc, opts ...RouteWrapper) Route {
return NewRoute("DELETE", path, handler, opts...) return NewRoute(http.MethodDelete, path, handler, opts...)
} }
// NewOptionsRoute initializes a new route with the http method OPTIONS. // NewOptionsRoute initializes a new route with the http method OPTIONS.
func NewOptionsRoute(path string, handler httputils.APIFunc, opts ...RouteWrapper) Route { func NewOptionsRoute(path string, handler httputils.APIFunc, opts ...RouteWrapper) Route {
return NewRoute("OPTIONS", path, handler, opts...) return NewRoute(http.MethodOptions, path, handler, opts...)
} }
// NewHeadRoute initializes a new route with the http method HEAD. // NewHeadRoute initializes a new route with the http method HEAD.
func NewHeadRoute(path string, handler httputils.APIFunc, opts ...RouteWrapper) Route { func NewHeadRoute(path string, handler httputils.APIFunc, opts ...RouteWrapper) Route {
return NewRoute("HEAD", path, handler, opts...) return NewRoute(http.MethodHead, path, handler, opts...)
} }