core

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Nov 3, 2024 License: MIT Imports: 11 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(*WebContext) (any, *errs.Error)

ApiHandlerFunc represents the api handler function

type CliContext added in v0.6.0

type CliContext struct {
	*cli.Context
}

CliContext represents the command-line context

func WrapCilContext added in v0.6.0

func WrapCilContext(cliCtx *cli.Context) *CliContext

WrapCliContext returns a context wrapped by this file

func (*CliContext) GetClientLocale added in v0.6.0

func (c *CliContext) GetClientLocale() string

GetClientLocale returns the client locale name

func (*CliContext) GetContextId added in v0.6.0

func (c *CliContext) GetContextId() string

GetContextId returns the current context id

type CliHandlerFunc added in v0.6.0

type CliHandlerFunc func(*CliContext) error

CliHandlerFunc represents the cli handler function

type Context

type Context interface {
	GetContextId() string
	GetClientLocale() string
}

Context is the base context of ezBookkeeping

type CronContext added in v0.6.0

type CronContext struct {
	context.Context
	// contains filtered or unexported fields
}

CronContext represents the cron job context

func NewCronJobContext added in v0.6.0

func NewCronJobContext(cronJobName string, cronJobInterval time.Duration) *CronContext

NewCronJobContext returns a new cron job context

func (*CronContext) GetClientLocale added in v0.6.0

func (c *CronContext) GetClientLocale() string

GetClientLocale returns the client locale name

func (*CronContext) GetContextId added in v0.6.0

func (c *CronContext) GetContextId() string

GetContextId returns the current context id

func (*CronContext) GetInterval added in v0.6.0

func (c *CronContext) GetInterval() time.Duration

GetInterval returns the current cron job interval

type CurrencyDisplayType added in v0.6.0

type CurrencyDisplayType byte

CurrencyDisplayType represents the display type of amount with currency

const (
	CURRENCY_DISPLAY_TYPE_DEFAULT                            CurrencyDisplayType = 0
	CURRENCY_DISPLAY_TYPE_NONE                               CurrencyDisplayType = 1
	CURRENCY_DISPLAY_TYPE_SYMBOL_BEFORE_AMOUNT               CurrencyDisplayType = 2
	CURRENCY_DISPLAY_TYPE_SYMBOL_AFTER_AMOUNT                CurrencyDisplayType = 3
	CURRENCY_DISPLAY_TYPE_SYMBOL_BEFORE_AMOUNT_WITHOUT_SPACE CurrencyDisplayType = 4
	CURRENCY_DISPLAY_TYPE_SYMBOL_AFTER_AMOUNT_WITHOUT_SPACE  CurrencyDisplayType = 5
	CURRENCY_DISPLAY_TYPE_CODE_BEFORE_AMOUNT                 CurrencyDisplayType = 6
	CURRENCY_DISPLAY_TYPE_CODE_AFTER_AMOUNT                  CurrencyDisplayType = 7
	CURRENCY_DISPLAY_TYPE_UNIT_BEFORE_AMOUNT                 CurrencyDisplayType = 8
	CURRENCY_DISPLAY_TYPE_UNIT_AFTER_AMOUNT                  CurrencyDisplayType = 9
	CURRENCY_DISPLAY_TYPE_NAME_BEFORE_AMOUNT                 CurrencyDisplayType = 10
	CURRENCY_DISPLAY_TYPE_NAME_AFTER_AMOUNT                  CurrencyDisplayType = 11
	CURRENCY_DISPLAY_TYPE_INVALID                            CurrencyDisplayType = 255
)

Currency Display Type

func (CurrencyDisplayType) String added in v0.6.0

func (d CurrencyDisplayType) String() string

String returns a textual representation of the currency display type enum

type DataHandlerFunc

type DataHandlerFunc func(*WebContext) ([]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(*WebContext) ([]byte, string, *errs.Error)

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

type LongDateFormat added in v0.6.0

type LongDateFormat byte

LongDateFormat represents long date format

const (
	LONG_DATE_FORMAT_DEFAULT  LongDateFormat = 0
	LONG_DATE_FORMAT_YYYY_M_D LongDateFormat = 1
	LONG_DATE_FORMAT_M_D_YYYY LongDateFormat = 2
	LONG_DATE_FORMAT_D_M_YYYY LongDateFormat = 3
	LONG_DATE_FORMAT_INVALID  LongDateFormat = 255
)

Long Date Format

func (LongDateFormat) String added in v0.6.0

func (f LongDateFormat) String() string

String returns a textual representation of the long date format enum

type LongTimeFormat added in v0.6.0

type LongTimeFormat byte

LongTimeFormat represents long time format

const (
	LONG_TIME_FORMAT_DEFAULT    LongTimeFormat = 0
	LONG_TIME_FORMAT_HH_MM_SS   LongTimeFormat = 1
	LONG_TIME_FORMAT_A_HH_MM_SS LongTimeFormat = 2
	LONG_TIME_FORMAT_HH_MM_SS_A LongTimeFormat = 3
	LONG_TIME_FORMAT_INVALID    LongTimeFormat = 255
)

Long Time Format

func (LongTimeFormat) String added in v0.6.0

func (f LongTimeFormat) String() string

String returns a textual representation of the long time format enum

type MiddlewareHandlerFunc

type MiddlewareHandlerFunc func(*WebContext)

MiddlewareHandlerFunc represents the middleware handler function

type NullContext added in v0.6.0

type NullContext struct {
	context.Context
}

NullContext represents the null context

func NewNullContext added in v0.6.0

func NewNullContext() *NullContext

NewCronJobContext returns a new null context

func (*NullContext) GetClientLocale added in v0.6.0

func (c *NullContext) GetClientLocale() string

GetClientLocale returns the client locale name

func (*NullContext) GetContextId added in v0.6.0

func (c *NullContext) GetContextId() string

GetContextId returns the current context id

type ProxyHandlerFunc added in v0.3.0

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

ProxyHandlerFunc represents the reverse proxy handler function

type ShortDateFormat added in v0.6.0

type ShortDateFormat byte

ShortDateFormat represents short date format

const (
	SHORT_DATE_FORMAT_DEFAULT  ShortDateFormat = 0
	SHORT_DATE_FORMAT_YYYY_M_D ShortDateFormat = 1
	SHORT_DATE_FORMAT_M_D_YYYY ShortDateFormat = 2
	SHORT_DATE_FORMAT_D_M_YYYY ShortDateFormat = 3
	SHORT_DATE_FORMAT_INVALID  ShortDateFormat = 255
)

Short Date Format

func (ShortDateFormat) String added in v0.6.0

func (f ShortDateFormat) String() string

String returns a textual representation of the short date format enum

type ShortTimeFormat added in v0.6.0

type ShortTimeFormat byte

ShortTimeFormat represents short time format

const (
	SHORT_TIME_FORMAT_DEFAULT ShortTimeFormat = 0
	SHORT_TIME_FORMAT_HH_MM   ShortTimeFormat = 1
	SHORT_TIME_FORMAT_A_HH_MM ShortTimeFormat = 2
	SHORT_TIME_FORMAT_HH_MM_A ShortTimeFormat = 3
	SHORT_TIME_FORMAT_INVALID ShortTimeFormat = 255
)

Short Time Format

func (ShortTimeFormat) String added in v0.6.0

func (f ShortTimeFormat) String() string

String returns a textual representation of the short time format enum

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 UserAvatarProviderType added in v0.6.0

type UserAvatarProviderType string

UserAvatarProviderType represents type of the user avatar provider

const (
	USER_AVATAR_PROVIDER_INTERNAL UserAvatarProviderType = "internal"
	USER_AVATAR_PROVIDER_GRAVATAR UserAvatarProviderType = "gravatar"
)

User avatar provider 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

type WebContext added in v0.6.0

type WebContext struct {
	*gin.Context
}

WebContext represents the request and response context

func WrapWebContext added in v0.6.0

func WrapWebContext(ginCtx *gin.Context) *WebContext

WrapWebContext returns a context wrapped by this file

func (*WebContext) ClientPort added in v0.6.0

func (c *WebContext) ClientPort() uint16

func (*WebContext) GetClientLocale added in v0.6.0

func (c *WebContext) GetClientLocale() string

GetClientLocale returns the client locale name

func (*WebContext) GetClientTimezoneOffset added in v0.6.0

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

GetClientTimezoneOffset returns the client timezone offset

func (*WebContext) GetContextId added in v0.6.0

func (c *WebContext) GetContextId() string

GetContextId returns the current request id

func (*WebContext) GetCurrentUid added in v0.6.0

func (c *WebContext) GetCurrentUid() int64

GetCurrentUid returns the current user uid by the current user token

func (*WebContext) GetResponseError added in v0.6.0

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

GetResponseError returns the response error

func (*WebContext) GetTextualToken added in v0.6.0

func (c *WebContext) GetTextualToken() string

GetTextualToken returns the current user textual token

func (*WebContext) GetTokenClaims added in v0.6.0

func (c *WebContext) GetTokenClaims() *UserTokenClaims

GetTokenClaims returns the current user token

func (*WebContext) SetContextId added in v0.6.0

func (c *WebContext) SetContextId(requestId string)

SetContextId sets the given request id to context

func (*WebContext) SetResponseError added in v0.6.0

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

SetResponseError sets the response error

func (*WebContext) SetTextualToken added in v0.6.0

func (c *WebContext) SetTextualToken(token string)

SetTextualToken sets the given user token to context

func (*WebContext) SetTokenClaims added in v0.6.0

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

SetTokenClaims sets the given user token to context

type WeekDay added in v0.6.0

type WeekDay byte

WeekDay represents week day

const (
	WEEKDAY_SUNDAY    WeekDay = 0
	WEEKDAY_MONDAY    WeekDay = 1
	WEEKDAY_TUESDAY   WeekDay = 2
	WEEKDAY_WEDNESDAY WeekDay = 3
	WEEKDAY_THURSDAY  WeekDay = 4
	WEEKDAY_FRIDAY    WeekDay = 5
	WEEKDAY_SATURDAY  WeekDay = 6
	WEEKDAY_INVALID   WeekDay = 255
)

Week days

func (WeekDay) String added in v0.6.0

func (d WeekDay) String() string

String returns a textual representation of the week day enum

Jump to

Keyboard shortcuts

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