common

package
v0.376.0 Latest Latest
Warning

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

Go to latest
Published: Jan 17, 2024 License: AGPL-3.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// An unexpected internal error happened.
	ErrInternal = "ERR_INTERNAL"
	// The input arguments provided are not valid.
	ErrInvalidInput = "ERR_INVALID_INPUT"
	// The input provided is malformed and cannot be parsed.
	ErrInputMalformed = "ERR_INPUT_MALFORMED"
	// Authentication failed when trying to identify the identity.
	ErrAuthenticationFailed = "ERR_AUTHENTICATION_FAILED"
	// Permission denied when trying to access some resource.
	ErrPermissionDenied = "ERR_PERMISSION_DENIED"
	// Record cannot be found with the provided parameters.
	ErrRecordNotFound = "ERR_RECORD_NOT_FOUND"
	// The path or action does not exist.
	ErrMethodNotFound = "ERR_ACTION_NOT_FOUND"
	// The HTTP method is not allowed for this request.
	ErrHttpMethodNotAllowed = "ERR_HTTP_METHOD_NOT_ALLOWED"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type HandlerFunc added in v0.372.0

type HandlerFunc func(r *http.Request) Response

type PermissionState

type PermissionState struct {
	Status PermissionStatus `json:"status"`
}

func NewPermissionState

func NewPermissionState() *PermissionState

func (*PermissionState) Grant

func (ps *PermissionState) Grant()

type PermissionStatus

type PermissionStatus string
const (
	PermissionGranted PermissionStatus = "granted"
	PermissionUnknown PermissionStatus = "unknown"
)

type Response

type Response struct {
	Status  int
	Body    []byte
	Headers map[string][]string
}

func InternalServerErrorResponse added in v0.373.0

func InternalServerErrorResponse(ctx context.Context, err error) Response

func NewJsonResponse

func NewJsonResponse(status int, body any, meta *ResponseMetadata) Response

func NewRedirectResponse added in v0.373.0

func NewRedirectResponse(url *url.URL) Response

type ResponseMetadata added in v0.373.0

type ResponseMetadata struct {
	Headers http.Header
	Status  int
}

type RuntimeError

type RuntimeError struct {
	Code    string
	Message string
}

func NewAuthenticationFailedErr

func NewAuthenticationFailedErr() RuntimeError

func NewAuthenticationFailedMessageErr added in v0.368.0

func NewAuthenticationFailedMessageErr(message string) RuntimeError

func NewForeignKeyConstraintError

func NewForeignKeyConstraintError(column string) RuntimeError

func NewHttpMethodNotAllowedError added in v0.368.0

func NewHttpMethodNotAllowedError(message string) RuntimeError

func NewInputMalformedError added in v0.368.0

func NewInputMalformedError(message string) RuntimeError

func NewMethodNotFoundError added in v0.368.0

func NewMethodNotFoundError() RuntimeError

func NewNotFoundError

func NewNotFoundError() RuntimeError

func NewNotNullError

func NewNotNullError(column string) RuntimeError

func NewPermissionError

func NewPermissionError() RuntimeError

func NewUniquenessError

func NewUniquenessError(columns []string) RuntimeError

func NewValidationError added in v0.368.0

func NewValidationError(message string) RuntimeError

func (RuntimeError) Error

func (r RuntimeError) Error() string

func (RuntimeError) Extensions

func (r RuntimeError) Extensions() map[string]any

Jump to

Keyboard shortcuts

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