add endpoint for delete

This commit is contained in:
Cubicroot 2021-06-06 19:30:25 +02:00
parent 3834e90527
commit b392ea1b44
6 changed files with 65 additions and 34 deletions

View file

@ -8,6 +8,10 @@ type idInURI struct {
ID uint `uri:"id" binding:"required"`
}
type messageIdInURI struct {
MessageID string `uri:"messageid" binding:"required"`
}
// RequireIDInURI returns a Gin middleware which requires an ID to be supplied in the URI of the request.
func RequireIDInURI() gin.HandlerFunc {
return func(ctx *gin.Context) {
@ -20,3 +24,16 @@ func RequireIDInURI() gin.HandlerFunc {
ctx.Set("id", requestModel.ID)
}
}
// RequireMessageIDInURI returns a Gin middleware which requires an messageID to be supplied in the URI of the request.
func RequireMessageIDInURI() gin.HandlerFunc {
return func(ctx *gin.Context) {
var requestModel messageIdInURI
if err := ctx.BindUri(&requestModel); err != nil {
return
}
ctx.Set("messageid", requestModel.MessageID)
}
}