gin_context

package
v0.4.2 Latest Latest
Warning

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

Go to latest
Published: Dec 19, 2022 License: GPL-3.0 Imports: 10 Imported by: 9

README

Package gin_context is highly binding with our business logic, not recommend to use in your service.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Handler

func Handler[T any](handler HandlerFunc[T]) gin.HandlerFunc

func Init

func Init(_contextDependence ContextDependence)

func InitInternalContext

func InitInternalContext(_internalContextDependence InternalContextDependence)

func InternalHandler

func InternalHandler(handler InternalHandlerFunc) gin.HandlerFunc

func MatchLanguage

func MatchLanguage(header string, tags []string) []string

func NoSecurityHandler

func NoSecurityHandler(handler NoSecurityHandlerFunc) gin.HandlerFunc

func ParseAuthorizationBearerHeader

func ParseAuthorizationBearerHeader(authHeader string) string

ParseAuthorizationBearerHeader Parse HTTP Authorization header with Bearer credentials. Return an empty string when parsing fails.

See also: https://datatracker.ietf.org/doc/html/rfc6750#section-2.1

Types

type Context

type Context[T any] struct {
	C         *gin.Context
	Languages []string
	Jwt       string
	Payload   T
}

func (*Context[T]) Language

func (c *Context[T]) Language() string

type ContextDependence

type ContextDependence struct {
	Auther      auth.Authable
	CustomLogic CustomLogic
}

type CustomLogic

type CustomLogic = func(claims jwt.MapClaims, c *gin.Context) error

type HandlerFunc

type HandlerFunc[T any] func(*Context[T])

type InternalContext

type InternalContext struct {
	UserId                     int
	InternalAuthorizationToken string
	C                          *gin.Context
}

type InternalContextDependence

type InternalContextDependence struct {
	AuthorizationToken string
	CustomLogic        CustomLogic
}

type InternalHandlerFunc

type InternalHandlerFunc func(ctx *InternalContext)

type NoSecurityContext

type NoSecurityContext struct {
	C *gin.Context
}

type NoSecurityHandlerFunc

type NoSecurityHandlerFunc func(ctx *NoSecurityContext)

Jump to

Keyboard shortcuts

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