@@ -72,6 +72,20 @@ func IsNoBodyMethod(method string) bool {
7272 return method != "POST" && method != "PUT" && method != "PATCH"
7373}
7474
75+ // IsValidMethod check method is valid
76+ func IsValidMethod (method string ) bool {
77+ method = strings .ToUpper (method )
78+ return http .MethodGet == method ||
79+ http .MethodPost == method ||
80+ http .MethodPut == method ||
81+ http .MethodPatch == method ||
82+ http .MethodDelete == method ||
83+ http .MethodConnect == method ||
84+ http .MethodHead == method ||
85+ http .MethodOptions == method ||
86+ http .MethodTrace == method
87+ }
88+
7589// BuildBasicAuth returns the base64 encoded username:password for basic auth.
7690// Then set to header "Authorization".
7791//
@@ -101,14 +115,14 @@ func SetHeaders(req *http.Request, headers ...http.Header) {
101115 }
102116}
103117
104- // AddHeaderMap to reqeust instance.
118+ // AddHeaderMap to request instance.
105119func AddHeaderMap (req * http.Request , headerMap map [string ]string ) {
106120 for k , v := range headerMap {
107121 req .Header .Add (k , v )
108122 }
109123}
110124
111- // SetHeaderMap to reqeust instance.
125+ // SetHeaderMap to request instance.
112126func SetHeaderMap (req * http.Request , headerMap map [string ]string ) {
113127 for k , v := range headerMap {
114128 req .Header .Set (k , v )
0 commit comments