app

package
v0.0.0-...-98a7bba Latest Latest
Warning

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

Go to latest
Published: Sep 15, 2024 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	LogKeyStatus       = "status"
	LogKeyIPAddress    = "ipAddress"
	LogKeyParams       = "params"
	LogKeyMethod       = "method"
	LogKeyHost         = "host"
	LogKeyPath         = "path"
	LogKeyTraceID      = "traceId"
	LogKeyAsyncTraceID = "asyncTraceId"
)
View Source
const DefaultMode = DevelopmentMode

DefaultMode is the default mode of the backend

View Source
const DevelopmentMode = "development"

DevelopmentMode indicates the backend is running in development mode This mode trades security for ease of use (Such as using unsecure cookies)

View Source
const MaxBodySize = 10 * 1024 * 1024 // 10MB
View Source
const MaxCommitFns = 1024
View Source
const MaxRollbackFns = 1024
View Source
const ProductionMode = "production"

ProductionMode indicates the backend is running in production mode This mode has the highest level of security

Variables

This section is empty.

Functions

This section is empty.

Types

type Asynchronous

type Asynchronous interface {
	AddJob(ctx Context, queue Queue, job Job) error
}

type Cache

type Cache interface {
	Set(ctx Context, key string, value interface{}, expiration time.Duration) error
	Get(ctx Context, key string) (CacheValue, error)
}

type CacheValue

type CacheValue interface {
	Name() string
	Val() string
	Result() (string, error)
	Bytes() ([]byte, error)
	Int() (int, error)
	Int64() (int64, error)
	Uint64() (uint64, error)
	Float32() (float32, error)
	Float64() (float64, error)
	Scan(val interface{}) error
	String() string
}

type CommitFn

type CommitFn func(ctx Context) error

type Config

type Config interface {
	GetAppName() string
	GetVersion() string
	GetMode() string
	GetDomain() string
	GetAllowableOrigin() string

	GetCacheHost() string
	GetCachePort() int32
	GetCachePassword() string

	GetDBHost() string
	GetDBPort() int32
	GetDBName() string
	GetDBUser() string
	GetDBPassword() string
	GetDBSSLMode() string

	GetJWTSecret() string
	GetJWTExpireIn() time.Duration

	DebugModeEnabled() bool

	GetEmailVerificationExpiresIn() time.Duration
	GetPasswordResetExpiresIn() time.Duration

	GetTestDatabaseConnection() string

	GetTimeoutInSeconds() time.Duration
}

Configuration is the main configuration file loader. The format is expected to be a toml file

type Context

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

func NewAsyncContext

func NewAsyncContext(baseCtx Context) Context

func NewContext

func NewContext() Context

func (Context) BeginTransaction

func (c Context) BeginTransaction() Context

func (Context) Cfg

func (c Context) Cfg() Config

Cfg returns the context configuration A config object must be set in every context, so if one does not exist, panic

func (Context) CommitTx

func (c Context) CommitTx() error

func (Context) IsDev

func (c Context) IsDev() bool

func (Context) IsProd

func (c Context) IsProd() bool

func (Context) IsSystemInitialized

func (c Context) IsSystemInitialized() bool

func (Context) Log

func (c Context) Log() Logger

Log returns the context logger

func (Context) MaxFileSizeInBytes

func (c Context) MaxFileSizeInBytes() uint64

func (Context) RegisterCommitFn

func (c Context) RegisterCommitFn(commitFn CommitFn)

func (Context) RegisterRollbackFn

func (c Context) RegisterRollbackFn(rollbackFn RollbackFn)

func (Context) RepositoryDriver

func (c Context) RepositoryDriver() RepositoryDriver

func (Context) Request

func (c Context) Request() Request

Request returns the context request

func (Context) RollbackTx

func (c Context) RollbackTx(err error) error

func (Context) RootDocumentID

func (c Context) RootDocumentID() ID

func (Context) Session

func (c Context) Session() Session

func (Context) StorageDocumentID

func (c Context) StorageDocumentID() ID

func (Context) StorageDriver

func (c Context) StorageDriver() StorageDriver

func (Context) TX

func (c Context) TX() *sqlx.Tx

func (Context) UseAsync

func (c Context) UseAsync(async Asynchronous) Context

func (Context) UseCache

func (c Context) UseCache(cache Cache) Context

func (Context) UseConfig

func (c Context) UseConfig(config Config) Context

func (Context) UseDB

func (c Context) UseDB(db *sqlx.DB) Context

func (Context) UseLogger

func (c Context) UseLogger(logger Logger) Context

func (Context) UseMaxFileSizeInBytes

func (c Context) UseMaxFileSizeInBytes(size uint64) Context

func (Context) UseRepositoryDriver

func (c Context) UseRepositoryDriver(driver RepositoryDriver) Context

func (Context) UseRequest

func (c Context) UseRequest(req *http.Request, routePath string) Context

func (Context) UseRootDocumentID

func (c Context) UseRootDocumentID(id ID) Context

func (Context) UseSession

func (c Context) UseSession(session Session) Context

func (Context) UseStorageDocumentID

func (c Context) UseStorageDocumentID(id ID) Context

func (Context) UseStorageDriver

func (c Context) UseStorageDriver(driver StorageDriver) Context

func (Context) UseSystemInitialize

func (c Context) UseSystemInitialize(initialized bool) Context

type ID

type ID uint64

func (ID) Empty

func (id ID) Empty() bool

func (ID) IsUnset

func (id ID) IsUnset() bool

func (ID) Ptr

func (id ID) Ptr() *ID

func (ID) String

func (id ID) String() string

type Job

type Job func(ctx Context) error

type Level

type Level uint8
const (
	LevelDebug Level = iota
	LevelInfo
	LevelWarning
	LevelError
)

type Logger

type Logger interface {
	SetLogLevel(level Level)
	WithStr(key string, value string) Logger
	WithInt(key string, value int) Logger
	Debug(format string)
	Info(format string)
	Warn(format string)
	Error(format string)
}

type ParamValue

type ParamValue string

func (ParamValue) AsInt

func (p ParamValue) AsInt(defaultValue int) int

func (ParamValue) AsString

func (p ParamValue) AsString() string

type Params

type Params map[string][]ParamValue

func (Params) Get

func (p Params) Get(key string) ParamValue

func (Params) GetAllByKey

func (p Params) GetAllByKey(key string) []ParamValue

func (Params) String

func (p Params) String() string

type Path

type Path string

func (Path) Append

func (p Path) Append(childPath Path) Path

func (Path) AppendTo

func (p Path) AppendTo(parentPath Path) Path

func (Path) String

func (p Path) String() string

type Queue

type Queue string
const (
	GeneralQueue Queue = "general"
)

type RepositoryDriver

type RepositoryDriver string
const (
	RepositoryDriverPostgres RepositoryDriver = "postgres"
)

type Request

type Request struct {
	// contains filtered or unexported fields
}

func NewRequest

func NewRequest(req *http.Request, routePath string) Request

func (Request) Body

func (Request) CurrentRole

func (r Request) CurrentRole() string

func (Request) FullPath

func (r Request) FullPath() string

func (Request) Host

func (r Request) Host() string

func (Request) IPAddress

func (r Request) IPAddress() string

func (Request) IsAuthenticated

func (r Request) IsAuthenticated() bool

func (Request) Method

func (r Request) Method() string

func (Request) Path

func (r Request) Path() string

func (Request) QueryParams

func (r Request) QueryParams() Params

type RollbackFn

type RollbackFn func(ctx Context, err error) error

type Session

type Session struct {
	Email  string
	UserID ID
}

type StorageDriver

type StorageDriver string
const (
	StorageDriverLocal StorageDriver = "local"
)

type WorkerPool

type WorkerPool interface {
	Start()
	AddJob(ctx Context, job Job) error
}

Directories

Path Synopsis
config
log

Jump to

Keyboard shortcuts

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