remove check body
This commit is contained in:
parent
8c6ef9c3cc
commit
9934ef91c0
@ -1,19 +0,0 @@
|
||||
package photosapi
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"net/http"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
var (
|
||||
ErrReqMissingBody = errors.New("missing body")
|
||||
)
|
||||
|
||||
func (s *Service) RequireBody(c *gin.Context) {
|
||||
if c.Request.Method == "POST" && c.Request.ContentLength == 0 {
|
||||
c.AbortWithError(http.StatusBadRequest, ErrReqMissingBody)
|
||||
return
|
||||
}
|
||||
}
|
8
internal/photos/api/default.go
Normal file
8
internal/photos/api/default.go
Normal file
@ -0,0 +1,8 @@
|
||||
package photosapi
|
||||
|
||||
import "github.com/gin-gonic/gin"
|
||||
|
||||
func (s *Service) DefaultJSON(c *gin.Context) {
|
||||
c.Header("content-type", "application/json; charset=utf-8")
|
||||
c.Next()
|
||||
}
|
@ -52,8 +52,8 @@ func (s *Service) SetupRoutes() {
|
||||
s.Gin.Use(
|
||||
gin.Logger(),
|
||||
s.Recovery,
|
||||
s.DefaultJSON,
|
||||
s.HandleError,
|
||||
s.RequireBody,
|
||||
)
|
||||
|
||||
s.AccountInit()
|
||||
|
Loading…
x
Reference in New Issue
Block a user