Documentation
¶
Index ¶
Constants ¶
View Source
const ( RoleAdmin Role = "ROLE_ADMIN" RoleUser = "ROLE_USER" RoleBadgeCreator = "ROLE_BADGE_CREATOR" )
Existing roles
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Policy ¶
Policy defines a match table between roles, http headers and allowed values
type RolePolicy ¶
RolePolicy defines an indexed list of Role
func BuildRolePolicy ¶
func BuildRolePolicy(policy Policy, r *http.Request) RolePolicy
BuildRolePolicy returns a map of Role matching the given http request
func (RolePolicy) HasAll ¶
func (policy RolePolicy) HasAll(roles ...Role) bool
HasAll returns a gin handler that checks the request against the given role
func (RolePolicy) HasOne ¶
func (policy RolePolicy) HasOne(roles ...Role) bool
HasOne returns a gin handler that checks the request against the given role
func (RolePolicy) ToSlice ¶
func (policy RolePolicy) ToSlice() (roles []Role)
ToSlice returns a slice of roles
Source Files
¶
- policy.go
- type.go
Click to show internal directories.
Click to hide internal directories.