contracts

package
v1.9.7 Latest Latest
Warning

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

Go to latest
Published: Sep 23, 2025 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrInvalidCipherText = fmt.Errorf("invalid cipherText")

Functions

This section is empty.

Types

type Activity added in v1.4.0

type Activity interface {
	CauserUserId() string
	ImpersonatorUserId() *string
}

type ActivityLogBuilder added in v1.4.0

type ActivityLogBuilder interface {
	Causer(user *models.User) ActivityLogBuilder
	Build() Activity
}

type ActivityLogService added in v1.4.0

type ActivityLogService interface {
	Log(ctx context.Context, activity Activity, action string) error
	Builder() ActivityLogBuilder
}

type Application

type Application interface {
	Context() context.Context
	Config() map[string]interface{}
	ListProvidedServices() []string
	Injector() *do.Injector
	Services() ApplicationServices
	Shutdown() error
}

type ApplicationServices

type ApplicationServices struct {
	Auth        AuthService
	ActivityLog ActivityLogService
	Crypt       CryptService
	Database    DatabaseService
	Event       EventService
	Logging     LoggingService
	Middleware  MiddlewareService
	Module      ModuleService
	Session     SessionService
	WebEngine   *web.Engine
}

type AuthGuard

type AuthGuard interface {
	User(ctx *web.Context) *models.User
	SetUser(ctx *web.Context, user *models.User)
}

type AuthGuardConstructor

type AuthGuardConstructor = func(application Application) (AuthGuard, error)

type AuthService

type AuthService interface {
	Login(ctx *web.Context, user *models.User) error
	Logout(ctx *web.Context) error
	User(ctx *web.Context) (*models.User, error)
	RegisterGuard(name string, constructor AuthGuardConstructor) error
}

type CryptService

type CryptService interface {
	Encrypt(plainText []byte) ([]byte, error)
	Decrypt(cipherText []byte) ([]byte, error)
}

type DatabaseService

type DatabaseService interface {
	GetDatabase(name string) *database.Database
	GetDefault() *database.Database
}

type Event

type Event interface {
	Name() string
	OccuredOn() time.Time
	JSON() ([]byte, error)
}

The minimal interface DomainEvent, implemented by all events, ensures support of an occurredOn() accessor. It enforces a basic contract for all events.

References:

  1. Implementing Domain-Driven Design, Vaughn Vernon

type EventListener

type EventListener interface {
	Name() string
	Handle(ctx context.Context, event Event) error
}

type EventListenerConstructor

type EventListenerConstructor = func(application Application) (EventListener, error)

type EventService

type EventService interface {
	Dispatch(ctx context.Context, payload Event)
	Register(name string, listenersConstructor []EventListenerConstructor)
}

type LoggingService added in v1.4.0

type LoggingService interface {
	Debug(ctx context.Context, message string) error
	Info(ctx context.Context, message string) error
	Notice(ctx context.Context, message string) error
	Warning(ctx context.Context, message string) error
	Error(ctx context.Context, message string) error
	Critical(ctx context.Context, message string) error
	Alert(ctx context.Context, message string) error
	Emergency(ctx context.Context, message string) error
}

type Middleware

type Middleware interface {
	Handle(param interface{}) web.HandlerFunc
}

type MiddlewareConstructor

type MiddlewareConstructor = func(application Application) (Middleware, error)

type MiddlewareService

type MiddlewareService interface {
	Use(name string, params interface{}) web.HandlerFunc
	Global() []web.HandlerFunc
	Register(name string, constructor MiddlewareConstructor) error
}

type Module

type Module interface {
	Name() string
	App() Application
}

type ModuleEntrypoint

type ModuleEntrypoint = func(mod Module)

type ModuleService

type ModuleService interface {
	Register(name string, entrypoint ModuleEntrypoint)
}

type ScriptCommand

type ScriptCommand interface {
	Key() string
	Name() string
	Description() string
	Usage() string
	Handler(args []string) error
}

type SentryConfig added in v1.9.6

type SentryConfig struct {
	Enabled bool `env:"SENTRY_ENABLED,default=false"`
	Debug   bool `env:"SENTRY_DEBUG,default=false"`

	// sentry config
	Dsn              string  `env:"SENTRY_DSN,required"`
	EnableTracing    bool    `env:"SENTRY_ENABLE_TRACING,default=false"`
	TracesSampleRate float64 `env:"SENTRY_TRACES_SAMPLE_RATE,default=0"`
	SendDefaultPii   bool    `env:"SENTRY_SEND_DEFAULT_PII,default=true"`

	// sentrygin specific config
	GinRepanic         bool `env:"SENTRY_GIN_REPANIC,default=true"`
	GinWaitForDelivery bool `env:"SENTRY_GIN_WAIT_FOR_DELIVERY, default=false"`
	GinTimeout         int  `env:"SENTRY_GIN_TIMEOUT,default=5"`
}

type SentryService added in v1.9.6

type SentryService interface {
	IsEnabled() bool
	IsDebug() bool
	IsTracingEnabled() bool
	IsDefaultPiiSent() bool
	MustRepanicGin() bool
	MustWaitForDeliveryGin() bool
	GetDsn() string
	GetTracesSampleRate() float64
	GetTimeoutGin() time.Duration
}

type SessionCookieWriter

type SessionCookieWriter interface {
	Write(ctx *web.Context, sess SessionData)
}

type SessionData

type SessionData interface {
	Id() string
	CSRFToken() string
	Get(key string) (interface{}, bool)
	Set(key string, value interface{})
	Delete(key string)
	Clear()
	RegenerateId()
	RegenerateCSRFToken()
	Data() map[string]interface{}
	ExpiredAt() time.Time
}

type SessionService

type SessionService interface {
	Get(ctx *web.Context, key string) (interface{}, error)
	IsTokenMatch(ctx *web.Context, token string) (bool, error)
	Put(ctx *web.Context, key string, value interface{}) error
	Delete(ctx *web.Context, key string) error
	Clear(ctx *web.Context) error
	Regenerate(ctx *web.Context) error
	Invalidate(ctx *web.Context) error
	RegenerateToken(ctx *web.Context) error
	Start(ctx *web.Context) error
}

type SessionStorage

type SessionStorage interface {
	Get(ctx context.Context, id string) (SessionData, error)
	Save(ctx context.Context, data SessionData) error
	Delete(ctx context.Context, id string) error
}

type StatefulAuthGuard

type StatefulAuthGuard interface {
	AuthGuard
	Login(ctx *web.Context, user *models.User) error
	Logout(ctx *web.Context) error
}

Jump to

Keyboard shortcuts

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