📝 Add godocs
This commit is contained in:
parent
2324d738bc
commit
e736978b93
3 changed files with 31 additions and 0 deletions
|
|
@ -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)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue