contracts

package
v1.7.1 Latest Latest
Warning

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

Go to latest
Published: Jun 27, 2024 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(activity Activity, action string)
	Builder() ActivityLogBuilder
}

type Application

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

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 LoggingDriver added in v1.4.0

type LoggingDriver interface {
	Debug(message string, context map[string]interface{})
	Info(message string, context map[string]interface{})
	Notice(message string, context map[string]interface{})
	Warning(message string, context map[string]interface{})
	Error(message string, context map[string]interface{})
	Critical(message string, context map[string]interface{})
	Alert(message string, context map[string]interface{})
	Emergency(message string, context map[string]interface{})
}

type LoggingDriverConstructor added in v1.4.0

type LoggingDriverConstructor func(config map[string]interface{}) LoggingDriver

type LoggingService added in v1.4.0

type LoggingService interface {
	Debug(message string, context map[string]interface{}) error
	Info(message string, context map[string]interface{}) error
	Notice(message string, context map[string]interface{}) error
	Warning(message string, context map[string]interface{}) error
	Error(message string, context map[string]interface{}) error
	Critical(message string, context map[string]interface{}) error
	Alert(message string, context map[string]interface{}) error
	Emergency(message string, context map[string]interface{}) error
	RegisterDriver(name string, construct LoggingDriverConstructor) 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 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