37 lines
454 B
Go
37 lines
454 B
Go
package api
|
|
|
|
import "fmt"
|
|
|
|
type HTTPMethod int
|
|
|
|
const (
|
|
Get HTTPMethod = iota
|
|
Post
|
|
Put
|
|
Patch
|
|
Delete
|
|
Options
|
|
Head
|
|
)
|
|
|
|
func HTTPMethod2String(method HTTPMethod) string {
|
|
switch method {
|
|
case Get:
|
|
return "GET"
|
|
case Post:
|
|
return "POST"
|
|
case Put:
|
|
return "PUT"
|
|
case Delete:
|
|
return "DELETE"
|
|
case Patch:
|
|
return "PATCH"
|
|
case Options:
|
|
return "OPTIONS"
|
|
case Head:
|
|
return "HEAD"
|
|
default:
|
|
return fmt.Sprintf("unknown: %d", method)
|
|
}
|
|
}
|