config

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: May 3, 2024 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ActveGinContext *gin.Context
View Source
var BarmouryGormDb *gorm.DB

Functions

func RegisterErrorAdvisers

func RegisterErrorAdvisers(engine *gin.Engine, opts ErrorAdviserOption, advisers []any)

func RegisterJwt

func RegisterJwt(engine *gin.Engine, opts JwtManagerOption)

func RegisterRouteValidators

func RegisterRouteValidators(engine *gin.Engine, validators []RouteValidator)

func ShouldNotFilter

func ShouldNotFilter(c *gin.Context, prefix string, openUrlPatterns []IRoute) bool

func UseDeferedHandlers

func UseDeferedHandlers(engine *gin.Engine)

Types

type BacuatorInterface

type BacuatorInterface interface {
	Resources() []any
	IsServiceOk() bool
	Controllers() []any
	ServiceName() string
	IconLocation() string
	ServiceApiName() string
	DownloadsCount() uint64
	ServiceDescription() string
	DatabaseQueryRoute() string
	LogUrls() []map[string]string
	UserStatistics() map[string]uint64
	DatabaseMultipleQueryRoute() string
	EarningStatistics() map[string]uint64
	PrincipalCan(g *gin.Context, dbMethod string) bool
	meta.IAnotation
}

type ErrorAdviser

type ErrorAdviser struct {
}

func (ErrorAdviser) AttributesAnnotations

func (e ErrorAdviser) AttributesAnnotations() map[string]map[string]any

func (ErrorAdviser) BadRequestErrors

func (e ErrorAdviser) BadRequestErrors(err error, opts ErrorAdviserOption) any

@ErrorAdvise{ Errors: ["invalid request payload"], StatusCode: 400 }

func (ErrorAdviser) DatabaseErrors

func (e ErrorAdviser) DatabaseErrors(err error, opts ErrorAdviserOption) any

@ErrorAdvise{ Errors: ["error in your SQL syntax"], StatusCode: 400 }

func (ErrorAdviser) ForbiddenErrors

func (e ErrorAdviser) ForbiddenErrors(err error, opts ErrorAdviserOption) any

@ErrorAdvise{ Errors: ["sql injection attack detected", "user details validation failed", "you do not have the required role"], StatusCode: 403 }

func (ErrorAdviser) MethodNotAllowedErrors

func (e ErrorAdviser) MethodNotAllowedErrors(err error, opts ErrorAdviserOption) any

@ErrorAdvise{ Errors: ["route is not supported"], StatusCode: 405 }

func (ErrorAdviser) MethodNotImplemented

func (e ErrorAdviser) MethodNotImplemented(err error, opts ErrorAdviserOption) any

@ErrorAdvise{ Errors: ["the method is not supported for this route"], StatusCode: 501 }

func (ErrorAdviser) RouteNotFound

func (e ErrorAdviser) RouteNotFound(err error, opts ErrorAdviserOption) any

@ErrorAdvise{ Errors: ["404 page not found", "found with the specified id"], StatusCode: 404 }

func (ErrorAdviser) UnauthorizedErrors

func (e ErrorAdviser) UnauthorizedErrors(err error, opts ErrorAdviserOption) any

@ErrorAdvise{ Errors: ["authorization token is missing", "validation failed for the request", "the authorization token has expired", "the authorization token is malformed"], StatusCode: 401 }

type ErrorAdviserOption

type ErrorAdviserOption struct {
	Log func(...any)
}

type IRoute

type IRoute struct {
	Route  string
	Method string
}

type JwtManagerOption

type JwtManagerOption struct {
	Prefix          string
	AuthorityPrefix string
	OpenUrlPatterns []IRoute
	Secrets         map[string]string
	Encryptor       crypto.IEncryptor[any]
	Validate        func(*gin.Context, string, model.UserDetails[any]) bool
}

type RouteValidator

type RouteValidator struct {
	Prefix string
	Routes []IRoute
	Valid  func(*gin.Context) bool
}

type RouterOption

type RouterOption struct {
	Prefix      string
	Db          *gorm.DB
	LogLevel    log.Level
	RouterGroup *gin.RouterGroup
	Bacuator    BacuatorInterface
}

func RegisterControllers

func RegisterControllers(engine *gin.Engine, opts RouterOption, controllers []meta.IAnotation) RouterOption

Jump to

Keyboard shortcuts

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