Documentation ¶
Index ¶
- Constants
- func Authed(backend backends.Backend, cookieOptions *models.CookieOptions, ...) gin.HandlerFunc
- func ErrorResponse(c *gin.Context, code int, err error, validation ...map[string]string)
- func ForbiddenResponse(c *gin.Context, errs ...*ForbiddenErr)
- func GetID(c *gin.Context) (id string)
- func GetLogger(c ...*gin.Context) *zerolog.Logger
- func GetUser(c *gin.Context) (user *pkgModels.User, ok bool)
- func HasAll(required ...string) gin.HandlerFunc
- func HasAny(required ...string) gin.HandlerFunc
- func IDPath(path ...string) string
- func Init(opt models.Options) (*gin.Engine, *gin.RouterGroup, error)
- func NoContentResponse(c *gin.Context)
- func NotFoundResponse(c *gin.Context, errs ...*NotFoundErr)
- func SmartResponse(c *gin.Context, data interface{}, err error)
- func SuccessResponse(c *gin.Context, data interface{})
- func UnauthorisedResponse(c *gin.Context, errs ...*UnauthorisedErr)
- func ValidationErrorResponse(c *gin.Context, errs ...*ValidationErr)
- type AuthOptions
- type BackendOptions
- type CookieOptions
- type ForbiddenErr
- type GenericErr
- type JWTOptions
- type LogOptions
- type NotFoundErr
- type OIDCOptions
- type Options
- type PermissionsOptions
- type ResponseModel
- type UnauthorisedErr
- type ValidationErr
Constants ¶
const GlobalKey = constants.GlobalKey
GlobalKey is a const for global validation errors
Variables ¶
This section is empty.
Functions ¶
func Authed ¶ added in v1.1.2
func Authed(backend backends.Backend, cookieOptions *models.CookieOptions, jwtOptions *models.JWTOptions, authOptions *models.AuthOptions, permissionOptions *models.PermissionsOptions, cancel bool) gin.HandlerFunc
Authed is a middleware that requires a user be authenticated. If cancel is set to false the request will be allowed to continue, but tonic.GetUser will return false
func ErrorResponse ¶ added in v1.1.2
ErrorResponse returns a new ErrorResponse, use at the end of a request
func ForbiddenResponse ¶ added in v1.1.2
func ForbiddenResponse(c *gin.Context, errs ...*ForbiddenErr)
ForbiddenResponse returns a new ForbiddenResponse, use at the end of a request
func HasAll ¶ added in v1.1.2
func HasAll(required ...string) gin.HandlerFunc
HasAny is a middleware that requires the user has all of the provided permissions to pass
func HasAny ¶ added in v1.1.2
func HasAny(required ...string) gin.HandlerFunc
HasAny is a middleware that requires the user has any of the provided permissions to pass
func NoContentResponse ¶ added in v1.1.2
NoContentResponse returns a new NoContentResponse, use at the end of a request
func NotFoundResponse ¶ added in v1.1.2
func NotFoundResponse(c *gin.Context, errs ...*NotFoundErr)
NotFoundResponse returns a new NotFoundResponse, use at the end of a request
func SmartResponse ¶ added in v1.1.2
SmartResponse returns a response object appropriate to the supplied error
func SuccessResponse ¶ added in v1.1.2
SuccessResponse returns a new SuccessResponse, use at the end of a request
func UnauthorisedResponse ¶ added in v1.1.2
func UnauthorisedResponse(c *gin.Context, errs ...*UnauthorisedErr)
UnauthorisedResponse returns a new UnauthorisedResponse, use at the end of a request
func ValidationErrorResponse ¶ added in v1.1.2
func ValidationErrorResponse(c *gin.Context, errs ...*ValidationErr)
ValidationErrorResponse returns a new ValidationErrorResponse, use at the end of a request
Types ¶
type AuthOptions ¶ added in v1.1.2
type AuthOptions = models.AuthOptions
type BackendOptions ¶ added in v1.1.2
type BackendOptions = models.BackendOptions
type CookieOptions ¶ added in v1.1.2
type CookieOptions = models.CookieOptions
type ForbiddenErr ¶ added in v1.1.2
type ForbiddenErr = errors.ForbiddenErr
Surface errors
func NewForbiddenError ¶ added in v1.1.2
func NewForbiddenError(required ...string) *ForbiddenErr
NewForbiddenError creates a new ForbiddenErr
type GenericErr ¶ added in v1.1.2
type GenericErr = errors.GenericErr
func NewGenericError ¶ added in v1.1.2
func NewGenericError(err ...error) *GenericErr
NewGenericError creates a new GenericErr
type JWTOptions ¶ added in v1.1.2
type JWTOptions = models.JWTOptions
type LogOptions ¶ added in v1.1.2
type LogOptions = models.LogOptions
type NotFoundErr ¶ added in v1.1.2
type NotFoundErr = errors.NotFoundErr
func NewNotFoundError ¶ added in v1.1.2
func NewNotFoundError(id string) *NotFoundErr
NewNotFoundError creates a new NotFoundErr
type OIDCOptions ¶ added in v1.1.2
type OIDCOptions = models.OIDCOptions
type PermissionsOptions ¶ added in v1.1.2
type PermissionsOptions = models.PermissionsOptions
type ResponseModel ¶ added in v1.1.2
type ResponseModel = api.ResponseModel
type UnauthorisedErr ¶ added in v1.1.2
type UnauthorisedErr = errors.UnauthorisedErr
func NewUnauthorisedError ¶ added in v1.1.2
func NewUnauthorisedError() *UnauthorisedErr
NewUnauthorisedError creates a new UnauthorisedErr
type ValidationErr ¶ added in v1.1.2
type ValidationErr = errors.ValidationErr
func NewValidationError ¶ added in v1.1.2
func NewValidationError(validation ...map[string]string) *ValidationErr
NewValidationError creates a new ValidationErr