16 lines
283 B
Go
16 lines
283 B
Go
package auth
|
|
|
|
import (
|
|
"errors"
|
|
|
|
"github.com/gin-gonic/gin"
|
|
)
|
|
|
|
func GetIDFromAuth(c *gin.Context) (string, error) {
|
|
auth := c.GetHeader("Authorization")
|
|
if len(auth) > 7 && auth[:7] == "Bearer " {
|
|
return auth[7:], nil
|
|
}
|
|
return "", errors.New("authorization token missing")
|
|
}
|