diff options
| author | Shulhan <ms@kilabit.info> | 2024-03-15 03:14:55 +0700 |
|---|---|---|
| committer | Shulhan <ms@kilabit.info> | 2024-03-15 03:39:16 +0700 |
| commit | 72f2c183724199c2b749ec8efb59aa20b59d9e96 (patch) | |
| tree | 5c37a4637399d778703c6a2b3f26aeca333ca1e4 /lib/http/request_method.go | |
| parent | b9e12300d9050143fcfaa2193ad91842f035661f (diff) | |
| download | pakakeh.go-72f2c183724199c2b749ec8efb59aa20b59d9e96.tar.xz | |
lib/http: refactoring type of RequestMethod from int to string
The reason is to make storing or encoding the RequestMethod value readable
from user point of view instead of number, 0, 1, 2, etc.
Diffstat (limited to 'lib/http/request_method.go')
| -rw-r--r-- | lib/http/request_method.go | 45 |
1 files changed, 10 insertions, 35 deletions
diff --git a/lib/http/request_method.go b/lib/http/request_method.go index 120fd55e..af0ade82 100644 --- a/lib/http/request_method.go +++ b/lib/http/request_method.go @@ -9,42 +9,17 @@ import ( ) // RequestMethod define type of HTTP method. -type RequestMethod int +type RequestMethod string // List of known HTTP methods. const ( - RequestMethodGet RequestMethod = iota - RequestMethodConnect - RequestMethodDelete - RequestMethodHead - RequestMethodOptions - RequestMethodPatch - RequestMethodPost - RequestMethodPut - RequestMethodTrace + RequestMethodConnect RequestMethod = http.MethodConnect + RequestMethodDelete RequestMethod = http.MethodDelete + RequestMethodGet RequestMethod = http.MethodGet + RequestMethodHead RequestMethod = http.MethodHead + RequestMethodOptions RequestMethod = http.MethodOptions + RequestMethodPatch RequestMethod = http.MethodPatch + RequestMethodPost RequestMethod = http.MethodPost + RequestMethodPut RequestMethod = http.MethodPut + RequestMethodTrace RequestMethod = http.MethodTrace ) - -// String return the string representation of request method. -func (rm RequestMethod) String() string { - switch rm { - 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 "" -} |
