mirror of
https://github.com/pushbits/server.git
synced 2025-04-30 18:57:17 +02:00
19 lines
336 B
Go
19 lines
336 B
Go
package api
|
|
|
|
import (
|
|
"errors"
|
|
"net/http"
|
|
|
|
"github.com/gin-gonic/gin"
|
|
)
|
|
|
|
func getID(ctx *gin.Context) (uint, error) {
|
|
id, ok := ctx.MustGet("id").(uint)
|
|
if !ok {
|
|
err := errors.New("an error occured while retrieving ID from context")
|
|
ctx.AbortWithError(http.StatusInternalServerError, err)
|
|
return 0, err
|
|
}
|
|
|
|
return id, nil
|
|
}
|