File size: 296 Bytes
fea99b3 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | package commonhttp
import (
"fmt"
"net/http"
"github.com/go-chi/render"
)
func JSONRequestBodyDecoder(r *http.Request, out any) error {
if err := render.DecodeJSON(r.Body, out); err != nil {
return NewHTTPError(http.StatusBadRequest, fmt.Errorf("decode json: %w", err))
}
return nil
}
|