util

package
v0.0.0-...-b37c17f Latest Latest
Warning

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

Go to latest
Published: May 12, 2024 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CheckTimestamp

func CheckTimestamp(timestamp int64) int64

CheckTimestamp ensures the timestamp is in ms

func Debounce

func Debounce(f func(), delay time.Duration) func()

Debounce returns a function that will invoke the provided function after the specified duration

func GetTimeoutContext

func GetTimeoutContext(second int) (context.Context, context.CancelFunc)

func GetTimestamp

func GetTimestamp() int64

GetTimestamp returns the current timestamp in ms

Types

type Claims

type Claims struct {
	jwt.RegisteredClaims
	Uuid     string `json:"uuid"`
	Username string `json:"username"`
	ClientId string `json:"clientId"`
}

func VerifyAndParse

func VerifyAndParse(token string, key *rsa.PublicKey) (*Claims, error)

type Configuration

type Configuration struct {
	TimeoutSecond      int      `json:"timeoutSecond"`
	HttpAddress        string   `json:"httpAddress"`
	LogFilePath        string   `json:"logFilePath"`
	Domain             string   `json:"domain"`
	AllowOrigins       []string `json:"allowOrigins"`
	AuthEnabled        bool     `json:"authEnabled"`
	CookiePathPrefix   string   `json:"cookiePathPrefix"`
	OAuthJwkPath       string   `json:"oAuthJwkPath"`
	OAuthAuthPath      string   `json:"oAuthAuthPath"`
	OAuthRefreshPath   string   `json:"oAuthRefreshPath"`
	OAuthClientId      string   `json:"oAuthClientId"`
	OAuthClientSecret  string   `json:"oAuthClientSecret"`
	OAuthIssuer        string   `json:"oAuthIssuer"`
	MongoDbUri         string   `json:"mongoDbUri"`
	MongoDbName        string   `json:"mongoDbName"`
	OpenAiOrgId        string   `json:"openAiOrgId"`
	OpenAiApiKey       string   `json:"openAiApiKey"`
	MessageLengthLimit int      `json:"messageLengthLimit"`
}

func NewConf

func NewConf(mode string) (*Configuration, error)

type ILogger

type ILogger interface {
	Printf(format string, args ...interface{})
	Println(any ...interface{})
	Warnf(format string, args ...interface{})
	Warnln(any ...interface{})
	Errorf(format string, args ...interface{})
	Errorln(any ...interface{})
	Close() error
}

type Jwk

type Jwk struct {
	Kty string `json:"kty"`
	E   string `json:"e"`
	Use string `json:"use"`
	Alg string `json:"alg"`
	N   string `json:"n"`
}

type Logger

type Logger struct {
	*log.Logger
	// contains filtered or unexported fields
}

func NewLogger

func NewLogger(conf *Configuration) (*Logger, error)

func (*Logger) Close

func (l *Logger) Close() error

func (*Logger) Errorf

func (l *Logger) Errorf(format string, args ...interface{})

func (*Logger) Errorln

func (l *Logger) Errorln(any ...interface{})

func (*Logger) Printf

func (l *Logger) Printf(format string, args ...interface{})

func (*Logger) Println

func (l *Logger) Println(any ...interface{})

func (*Logger) Warnf

func (l *Logger) Warnf(format string, args ...interface{})

func (*Logger) Warnln

func (l *Logger) Warnln(any ...interface{})

Jump to

Keyboard shortcuts

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