errorx

package
v0.6.0-alpha.2 Latest Latest
Warning

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

Go to latest
Published: May 7, 2021 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const RouteGet = "/self-service/errors"

Variables

This section is empty.

Functions

This section is empty.

Types

type ErrorContainer

type ErrorContainer struct {
	// ID of the error container.
	//
	// required: true
	ID  uuid.UUID `db:"id" json:"id"`
	NID uuid.UUID `json:"-" db:"nid"`

	// Errors in the container
	//
	// required: true
	Errors json.RawMessage `json:"errors" db:"errors"`

	// CreatedAt is a helper struct field for gobuffalo.pop.
	CreatedAt time.Time `json:"-" db:"created_at"`

	// UpdatedAt is a helper struct field for gobuffalo.pop.
	UpdatedAt time.Time `json:"-" db:"updated_at"`

	SeenAt    sql.NullTime `json:"-" db:"seen_at"`
	WasSeen   bool         `json:"-" db:"was_seen"`
	CSRFToken string       `db:"csrf_token" json:"-"`
}

swagger:model errorContainer

func (ErrorContainer) TableName

func (e ErrorContainer) TableName(ctx context.Context) string

type Handler

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

func NewHandler

func NewHandler(
	r handlerDependencies,
) *Handler

func (*Handler) RegisterAdminRoutes

func (h *Handler) RegisterAdminRoutes(public *x.RouterAdmin)

func (*Handler) RegisterPublicRoutes

func (h *Handler) RegisterPublicRoutes(public *x.RouterPublic)

func (*Handler) WithTokenGenerator

func (h *Handler) WithTokenGenerator(f func(r *http.Request) string)

type HandlerProvider

type HandlerProvider interface {
	SelfServiceErrorHandler() *Handler
}

type ManagementProvider

type ManagementProvider interface {
	// SelfServiceErrorManager returns the errorx.Manager.
	SelfServiceErrorManager() *Manager
}

type Manager

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

func NewManager

func NewManager(d managerDependencies) *Manager

func (*Manager) Create

func (m *Manager) Create(ctx context.Context, w http.ResponseWriter, r *http.Request, errs ...error) (string, error)

Create is a simple helper that saves all errors in the store and returns the error url, appending the error ID.

func (*Manager) Forward

func (m *Manager) Forward(ctx context.Context, w http.ResponseWriter, r *http.Request, errs ...error)

Forward is a simple helper that saves all errors in the store and forwards the HTTP Request to the error url, appending the error ID.

type PersistenceProvider

type PersistenceProvider interface {
	SelfServiceErrorPersister() Persister
}

type Persister

type Persister interface {
	// Add adds an error to the manager and returns a unique identifier or an error if insertion fails.
	Add(ctx context.Context, csrfToken string, errs ...error) (uuid.UUID, error)

	// Read returns an error by its unique identifier and marks the error as read. If an error occurs during retrieval
	// the second return parameter is an error.
	Read(ctx context.Context, id uuid.UUID) (*ErrorContainer, error)

	// Clear clears read containers that are older than a certain amount of time. If force is set to true, unread
	// errors will be cleared as well.
	Clear(ctx context.Context, olderThan time.Duration, force bool) error
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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