Documentation
¶
Index ¶
Constants ¶
View Source
const NotificationRole = "opensight_notification_role"
View Source
const UserRole = "user"
Variables ¶
View Source
var ErrorHandlers = []ErrorHandlerFunc{
handleUnauthorizedError,
}
ErrorHandlers is a slice of error handler functions. Each function is responsible for handling specific types of errors. All other error handling is currently done inside the handler for the specific endpoint.
Functions ¶
func AuthorizeRoles ¶
func AuthorizeRoles(authFunc gin.HandlerFunc, roles ...string) []gin.HandlerFunc
AuthorizeRoles adds role-based authorization middleware to the provided handler. It first executes the provided authentication function, then checks if the user has one of the required roles.
func CORS ¶ added in v0.8.0
func CORS(allowedOrigins []string) gin.HandlerFunc
func ErrorHandler ¶
func ErrorHandler(errorType gin.ErrorType) gin.HandlerFunc
ErrorHandler is a middleware that processes errors after the request context is finished. It iterates over registered error handlers to find one that can handle the error.
Types ¶
Click to show internal directories.
Click to hide internal directories.