core

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Apr 2, 2023 License: MIT Imports: 4 Imported by: 41

Documentation

Index

Constants

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

ClientTimezoneOffsetHeaderName represents the header name of client timezone offset

Variables

This section is empty.

Functions

This section is empty.

Types

type ApiHandlerFunc

type ApiHandlerFunc func(*Context) (interface{}, *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) 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) 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) SetTokenClaims

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

SetTokenClaims sets the given user token id to context

type DataHandlerFunc

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

DataHandlerFunc represents the handler function that returns byte array

type MiddlewareHandlerFunc

type MiddlewareHandlerFunc func(*Context)

MiddlewareHandlerFunc represents the middleware 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
)

Token types

type UserTokenClaims

type UserTokenClaims struct {
	UserTokenId string    `json:"userTokenId"`
	Username    string    `json:"username,omitempty"`
	Type        TokenType `json:"type"`
	jwt.StandardClaims
}

UserTokenClaims represents user token

Jump to

Keyboard shortcuts

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