diff options
| author | Shulhan <m.shulhan@gmail.com> | 2019-11-20 16:30:16 +0700 |
|---|---|---|
| committer | Shulhan <m.shulhan@gmail.com> | 2019-11-20 16:30:16 +0700 |
| commit | 8294d33fa6a15636f8e320dbc67f6ed447f77917 (patch) | |
| tree | 650072de22a1413752cd28c239bec342403504ae | |
| parent | 423d86879f80ab1dd57cb20ed9102d7da8c87a53 (diff) | |
| download | pakakeh.go-8294d33fa6a15636f8e320dbc67f6ed447f77917.tar.xz | |
http: add method HTTPMethod to Endpoint
The HTTPMethod will return the string representation of HTTP method
as predefined in "net/http".
| -rw-r--r-- | lib/http/endpoint.go | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/lib/http/endpoint.go b/lib/http/endpoint.go index 49fc0c28..3d7bab53 100644 --- a/lib/http/endpoint.go +++ b/lib/http/endpoint.go @@ -42,6 +42,34 @@ type Endpoint struct { Call Callback } +// +// HTTPMethod return the string representation of HTTP method as predefined +// in "net/http". +// +func (ep *Endpoint) HTTPMethod() string { + switch ep.Method { + case RequestMethodGet: + return http.MethodGet + case RequestMethodConnect: + return http.MethodConnect + case RequestMethodDelete: + return http.MethodDelete + case RequestMethodHead: + return http.MethodHead + case RequestMethodOptions: + return http.MethodOptions + case RequestMethodPatch: + return http.MethodPatch + case RequestMethodPost: + return http.MethodPost + case RequestMethodPut: + return http.MethodPut + case RequestMethodTrace: + return http.MethodTrace + } + return http.MethodGet +} + func (ep *Endpoint) call( res http.ResponseWriter, req *http.Request, |
