status.go 501 B

1234567891011121314151617181920212223242526272829
  1. package http
  2. const (
  3. ok = 200
  4. created = 201
  5. unauthorized = 401
  6. forbidden = 403
  7. internalServerError = 500
  8. )
  9. /**
  10. * 获取标准的 HTTP 状态码, -1 表示未找到
  11. */
  12. func GetHttpStatusByAlias(s string) int {
  13. switch s {
  14. case "ok":
  15. return ok
  16. case "created":
  17. return created
  18. case "unauthorized":
  19. return unauthorized
  20. case "forbidden":
  21. return forbidden
  22. case "internalServerError":
  23. return internalServerError
  24. default:
  25. return -1
  26. }
  27. }