Browse Source

constant replace string

Paul 6 years ago
parent
commit
3c7986ca62
1 changed files with 3 additions and 3 deletions
  1. 3
    3
      request/request.go

+ 3
- 3
request/request.go View File

1
 package request
1
 package request
2
 
2
 
3
 import (
3
 import (
4
+	"fmt"
4
 	"net/http"
5
 	"net/http"
5
 	"runtime"
6
 	"runtime"
6
 
7
 
7
-	"fmt"
8
 	"github.com/gin-gonic/gin"
8
 	"github.com/gin-gonic/gin"
9
 	"github.com/sirupsen/logrus"
9
 	"github.com/sirupsen/logrus"
10
 )
10
 )
55
 	}
55
 	}
56
 
56
 
57
 	switch ctx.Request.Method {
57
 	switch ctx.Request.Method {
58
-	case "GET", "PUT", "DELETE", "HEAD", "PATCH", "OPTIONS":
58
+	case http.MethodGet, http.MethodPut, http.MethodDelete, http.MethodHead, http.MethodPatch, http.MethodOptions:
59
 		ctx.JSON(http.StatusOK, data)
59
 		ctx.JSON(http.StatusOK, data)
60
-	case "POST":
60
+	case http.MethodPost:
61
 		ctx.JSON(http.StatusCreated, data)
61
 		ctx.JSON(http.StatusCreated, data)
62
 	default:
62
 	default:
63
 		ctx.JSON(http.StatusBadRequest, HTTPError{Msg: fmt.Sprintf("unsupported request method %s", ctx.Request.Method)})
63
 		ctx.JSON(http.StatusBadRequest, HTTPError{Msg: fmt.Sprintf("unsupported request method %s", ctx.Request.Method)})