contracts

package
v1.3.2 Latest Latest
Warning

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

Go to latest
Published: Feb 16, 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 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
	Crypt      CryptService
	Database   DatabaseService
	Event      EventService
	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 {
	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, name string, payload Event)
	Register(name string, listenersConstructor []EventListenerConstructor)
}

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
}

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