photos-api/internal/photos/api/check_body.go
2022-05-07 15:38:44 +02:00

20 lines
327 B
Go

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
}
}