📝 Add godocs

This commit is contained in:
Dan Jones 2024-01-22 20:08:03 -06:00
commit e736978b93
3 changed files with 31 additions and 0 deletions

View file

@ -7,6 +7,7 @@ import (
"github.com/gin-gonic/gin"
)
// Returns a gin middleware which writes a response with the error in the context.
func ErrorMiddleware(opts ...Option) gin.HandlerFunc {
conf := config{}
for _, opt := range opts {
@ -54,6 +55,7 @@ func ErrorMiddleware(opts ...Option) gin.HandlerFunc {
c.Set("rendered_error", re)
// @todo check a response hasn't already been sent
c.JSON(re.Status(), re)
}
}