Documentation ¶
Index ¶
- Variables
- func RegisterErrorAdvisers(engine *gin.Engine, opts ErrorAdviserOption, advisers []any)
- func RegisterJwt(engine *gin.Engine, opts JwtManagerOption)
- func RegisterRouteValidators(engine *gin.Engine, validators []RouteValidator)
- func ShouldNotFilter(c *gin.Context, prefix string, openUrlPatterns []IRoute) bool
- func UseDeferedHandlers(engine *gin.Engine)
- type BacuatorInterface
- type ErrorAdviser
- func (e ErrorAdviser) AttributesAnnotations() map[string]map[string]any
- func (e ErrorAdviser) BadRequestErrors(err error, opts ErrorAdviserOption) any
- func (e ErrorAdviser) DatabaseErrors(err error, opts ErrorAdviserOption) any
- func (e ErrorAdviser) ForbiddenErrors(err error, opts ErrorAdviserOption) any
- func (e ErrorAdviser) MethodNotAllowedErrors(err error, opts ErrorAdviserOption) any
- func (e ErrorAdviser) MethodNotImplemented(err error, opts ErrorAdviserOption) any
- func (e ErrorAdviser) RouteNotFound(err error, opts ErrorAdviserOption) any
- func (e ErrorAdviser) UnauthorizedErrors(err error, opts ErrorAdviserOption) any
- type ErrorAdviserOption
- type IRoute
- type JwtManagerOption
- type RouteValidator
- type RouterOption
Constants ¶
This section is empty.
Variables ¶
var ActveGinContext *gin.Context
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 UseDeferedHandlers ¶
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 JwtManagerOption ¶
type RouteValidator ¶
type RouterOption ¶
type RouterOption struct { InitDb bool 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