20 lines
327 B
Go
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
|
|
}
|
|
}
|