add path param lure customization

Signed-off-by: RonniSkansing <rskansing@gmail.com>
This commit is contained in:
RonniSkansing
2026-07-27 17:57:53 +02:00
parent dfcfafd502
commit fd7ca01b22
29 changed files with 1818 additions and 75 deletions
+12
View File
@@ -42,6 +42,7 @@ type JSONResponseHandler interface {
Forbidden(g *gin.Context)
BadRequest(g *gin.Context)
BadRequestMessage(g *gin.Context, message string)
Conflict(g *gin.Context, message string, data any)
ValidationFailed(g *gin.Context, field string, err error)
ServerError(g *gin.Context)
ServerErrorMessage(g *gin.Context, message string)
@@ -130,6 +131,17 @@ func (r *jsonResponseHandler) BadRequestMessage(g *gin.Context, message string)
g.Abort()
}
// Conflict responds with 409 - CONFLICT and carries enough detail for the
// caller to offer a resolution, such as naming the campaign already holding a
// lure code the operator asked for.
func (r *jsonResponseHandler) Conflict(g *gin.Context, message string, data any) {
g.JSON(
http.StatusConflict,
r.newResponse(false, data, message),
)
g.Abort()
}
func (r *jsonResponseHandler) unwrapErrorMessage(err error) string {
message := err.Error()
unwrapped := errors.Unwrap(err)