core

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Aug 10, 2024 License: MIT Imports: 8 Imported by: 41

Documentation

Index

Constants

View Source
const AcceptLanguageHeaderName = "Accept-Language"

AcceptLanguageHeaderName represents the header name of accept language

View Source
const ClientTimezoneOffsetHeaderName = "X-Timezone-Offset"

ClientTimezoneOffsetHeaderName represents the header name of client timezone offset

View Source
const RemoteClientPortHeader = "X-Real-Port"

RemoteClientPortHeader represents the header name of remote client source port

Variables

This section is empty.

Functions

This section is empty.

Types

type ApiHandlerFunc

type ApiHandlerFunc func(*Context) (any, *errs.Error)

ApiHandlerFunc represents the api handler function

type Context

type Context struct {
	*gin.Context
}

Context represents the request and response context

func WrapContext

func WrapContext(ginCtx *gin.Context) *Context

WrapContext returns a context wrapped by this file

func (*Context) ClientPort added in v0.5.0

func (c *Context) ClientPort() uint16

func (*Context) GetClientLocale added in v0.4.0

func (c *Context) GetClientLocale() string

GetClientLocale returns the client locale name

func (*Context) GetClientTimezoneOffset

func (c *Context) GetClientTimezoneOffset() (int16, error)

GetClientTimezoneOffset returns the client timezone offset

func (*Context) GetCurrentUid

func (c *Context) GetCurrentUid() int64

GetCurrentUid returns the current user uid by the current user token

func (*Context) GetRequestId

func (c *Context) GetRequestId() string

GetRequestId returns the current request id

func (*Context) GetResponseError

func (c *Context) GetResponseError() *errs.Error

GetResponseError returns the response error

func (*Context) GetTextualToken added in v0.4.0

func (c *Context) GetTextualToken() string

GetTextualToken returns the current user textual token

func (*Context) GetTokenClaims

func (c *Context) GetTokenClaims() *UserTokenClaims

GetTokenClaims returns the current user token

func (*Context) SetRequestId

func (c *Context) SetRequestId(requestId string)

SetRequestId sets the given request id to context

func (*Context) SetResponseError

func (c *Context) SetResponseError(error *errs.Error)

SetResponseError sets the response error

func (*Context) SetTextualToken added in v0.4.0

func (c *Context) SetTextualToken(token string)

SetTextualToken sets the given user token to context

func (*Context) SetTokenClaims

func (c *Context) SetTokenClaims(claims *UserTokenClaims)

SetTokenClaims sets the given user token to context

type DataHandlerFunc

type DataHandlerFunc func(*Context) ([]byte, string, *errs.Error)

DataHandlerFunc represents the handler function that returns file data byte array and file name

type DecimalSeparator added in v0.5.0

type DecimalSeparator byte

DecimalSeparator represents the type of decimal separator

const (
	DECIMAL_SEPARATOR_DEFAULT DecimalSeparator = 0
	DECIMAL_SEPARATOR_DOT     DecimalSeparator = 1
	DECIMAL_SEPARATOR_COMMA   DecimalSeparator = 2
	DECIMAL_SEPARATOR_SPACE   DecimalSeparator = 3
	DECIMAL_SEPARATOR_INVALID DecimalSeparator = 255
)

Decimal Separator

func (DecimalSeparator) String added in v0.5.0

func (f DecimalSeparator) String() string

String returns a textual representation of the decimal separator enum

type DigitGroupingSymbol added in v0.5.0

type DigitGroupingSymbol byte

DigitGroupingSymbol represents the digit grouping symbol

const (
	DIGIT_GROUPING_SYMBOL_DEFAULT    DigitGroupingSymbol = 0
	DIGIT_GROUPING_SYMBOL_DOT        DigitGroupingSymbol = 1
	DIGIT_GROUPING_SYMBOL_COMMA      DigitGroupingSymbol = 2
	DIGIT_GROUPING_SYMBOL_SPACE      DigitGroupingSymbol = 3
	DIGIT_GROUPING_SYMBOL_APOSTROPHE DigitGroupingSymbol = 4
	DIGIT_GROUPING_SYMBOL_INVALID    DigitGroupingSymbol = 255
)

Digit Grouping Symbol

func (DigitGroupingSymbol) String added in v0.5.0

func (f DigitGroupingSymbol) String() string

String returns a textual representation of the digit grouping symbol enum

type DigitGroupingType added in v0.5.0

type DigitGroupingType byte

DigitGroupingType represents digit grouping type

const (
	DIGIT_GROUPING_TYPE_DEFAULT             DigitGroupingType = 0
	DIGIT_GROUPING_TYPE_NONE                DigitGroupingType = 1
	DIGIT_GROUPING_TYPE_THOUSANDS_SEPARATOR DigitGroupingType = 2
	DIGIT_GROUPING_TYPE_INVALID             DigitGroupingType = 255
)

Digit Grouping Type

func (DigitGroupingType) String added in v0.5.0

func (d DigitGroupingType) String() string

String returns a textual representation of the digit grouping type enum

type ImageHandlerFunc added in v0.5.0

type ImageHandlerFunc func(*Context) ([]byte, string, *errs.Error)

ImageHandlerFunc represents the handler function that returns image byte array and content type

type MiddlewareHandlerFunc

type MiddlewareHandlerFunc func(*Context)

MiddlewareHandlerFunc represents the middleware handler function

type ProxyHandlerFunc added in v0.3.0

type ProxyHandlerFunc func(*Context) (*httputil.ReverseProxy, *errs.Error)

ProxyHandlerFunc represents the reverse proxy handler function

type TokenType

type TokenType byte

TokenType represents token type

const (
	USER_TOKEN_TYPE_NORMAL         TokenType = 1
	USER_TOKEN_TYPE_REQUIRE_2FA    TokenType = 2
	USER_TOKEN_TYPE_EMAIL_VERIFY   TokenType = 3
	USER_TOKEN_TYPE_PASSWORD_RESET TokenType = 4
)

Token types

type UserTokenClaims

type UserTokenClaims struct {
	UserTokenId string    `json:"userTokenId"`
	Uid         int64     `json:"jti,string"`
	Username    string    `json:"username,omitempty"`
	Type        TokenType `json:"type"`
	IssuedAt    int64     `json:"iat"`
	ExpiresAt   int64     `json:"exp"`
}

UserTokenClaims represents user token

func (*UserTokenClaims) GetAudience added in v0.3.0

func (c *UserTokenClaims) GetAudience() (jwt.ClaimStrings, error)

GetAudience returns the audience of this token

func (*UserTokenClaims) GetExpirationTime added in v0.3.0

func (c *UserTokenClaims) GetExpirationTime() (*jwt.NumericDate, error)

GetExpirationTime returns the expiration time of this token

func (*UserTokenClaims) GetIssuedAt added in v0.3.0

func (c *UserTokenClaims) GetIssuedAt() (*jwt.NumericDate, error)

GetIssuedAt returns the issue time of this token

func (*UserTokenClaims) GetIssuer added in v0.3.0

func (c *UserTokenClaims) GetIssuer() (string, error)

GetIssuer returns the issuer of this token

func (*UserTokenClaims) GetNotBefore added in v0.3.0

func (c *UserTokenClaims) GetNotBefore() (*jwt.NumericDate, error)

GetNotBefore returns the earliest valid time of this token

func (*UserTokenClaims) GetSubject added in v0.3.0

func (c *UserTokenClaims) GetSubject() (string, error)

GetSubject returns the subject of this token

Jump to

Keyboard shortcuts

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