mirror of
https://github.com/pushbits/server.git
synced 2025-05-11 16:07:04 +02:00
add endpoint for delete
This commit is contained in:
parent
3834e90527
commit
b392ea1b44
6 changed files with 65 additions and 34 deletions
|
@ -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)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue