decorators

package
v0.1.14 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 30, 2023 License: AGPL-3.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var CorsForm = forms.Form{
	ErrorMsg: "invalid data encountered in the Cors form",
	Fields: []forms.Field{
		{
			Name: "allowed-hosts",
			Validators: []forms.Validator{
				forms.IsRequired{},
				forms.IsStringList{},
			},
		},
		{
			Name: "allowed-headers",
			Validators: []forms.Validator{
				forms.IsOptional{Default: []string{}},
				forms.IsStringList{},
			},
		},
		{
			Name: "allowed-methods",
			Validators: []forms.Validator{
				forms.IsOptional{Default: []string{"GET", "POST", "PATCH", "PUT", "DELETE", "OPTIONS"}},
				forms.IsStringList{},
			},
		},
		{
			Name: "disable",
			Validators: []forms.Validator{
				forms.IsOptional{Default: false},
				forms.IsBoolean{},
			},
		},
	},
}
View Source
var ObjectIDForm = forms.Form{
	ErrorMsg: "invalid data encountered in the object ID form",
	Fields: []forms.Field{
		{
			Name: "object_id",
			Validators: []forms.Validator{
				forms.IsRequired{},
				forms.IsHex{ConvertToBinary: true},
			},
		},
	},
}

Functions

func AssociateType

func AssociateType(leftType, rightType string) gin.HandlerFunc

func BaseRateLimitSetup

func BaseRateLimitSetup(settings kodex.Settings, endpoints *gin.RouterGroup, meter kodex.Meter)

func CheckScopes

func CheckScopes(requiredScopes, userScopes []string) bool

func Cors

func Cors(settings kodex.Settings, defaultRoute bool) gin.HandlerFunc

func CorsFromEverywhere

func CorsFromEverywhere(settings kodex.Settings) gin.HandlerFunc

func IPMeterID

func IPMeterID(settings kodex.Settings) gin.HandlerFunc

func MeterEndpointCalls

func MeterEndpointCalls(meter kodex.Meter, meterId string) func(*gin.Context)

func Metered

func Metered(settings kodex.Settings, meter kodex.Meter) gin.HandlerFunc

func ObjectType

func ObjectType(objectType string) gin.HandlerFunc

func OrganizationMeterId

func OrganizationMeterId(settings kodex.Settings) gin.HandlerFunc

func RateLimited

func RateLimited(meter kodex.Meter, settings kodex.Settings, idName, rateLimitName string, tw kodex.TimeWindowFunc, rateLimitType RateLimitType, max int64) gin.HandlerFunc

func ValidObject

func ValidObject(settings kodex.Settings, objectType string, objectRoles []string, scopes []string) gin.HandlerFunc

func ValidOrganization

func ValidOrganization(orgRoles []string) gin.HandlerFunc

func ValidUser

func ValidUser(settings kodex.Settings, scopes []string, superUser bool) gin.HandlerFunc

Makes sure that the user has provided a valid access token. Stores the token, user ID and user in the context.

func WithController

func WithController(controller api.Controller) gin.HandlerFunc

func WithSettings

func WithSettings(settings kodex.Settings) gin.HandlerFunc

func WithValue

func WithValue(name string, value interface{}) gin.HandlerFunc

Types

type RateLimitType

type RateLimitType int
const (
	VolumeRateLimit RateLimitType = iota
	CallRateLimit
)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL