Restructure project layout

This commit is contained in:
eikendev 2021-01-16 16:56:49 +01:00
parent a49db216d5
commit 9a4a096526
No known key found for this signature in database
GPG key ID: A1BDB1B28C8EF694
32 changed files with 35 additions and 35 deletions

View file

@ -0,0 +1,22 @@
package api
import (
"github.com/gin-gonic/gin"
)
type idInURI struct {
ID uint `uri:"id" 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) {
var requestModel idInURI
if err := ctx.BindUri(&requestModel); err != nil {
return
}
ctx.Set("id", requestModel.ID)
}
}