common

package
v0.365.15 Latest Latest
Warning

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

Go to latest
Published: Sep 1, 2023 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ErrInternal             = "ERR_INTERNAL"
	ErrInvalidInput         = "ERR_INVALID_INPUT"
	ErrPermissionDenied     = "ERR_PERMISSION_DENIED"
	ErrRecordNotFound       = "ERR_RECORD_NOT_FOUND"
	ErrAuthenticationFailed = "ERR_AUTHENTICATION_FAILED"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type ApiHandlerFunc

type ApiHandlerFunc func(r *http.Request) Response

type HttpJsonErrorResponse

type HttpJsonErrorResponse struct {
	Code    string         `json:"code"`
	Message string         `json:"message"`
	Data    map[string]any `json:"data,omitempty"`
}

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 NewJsonErrorResponse

func NewJsonErrorResponse(err error) Response

func NewJsonResponse

func NewJsonResponse(status int, body any, headers map[string][]string) Response

type RuntimeError

type RuntimeError struct {
	Code    string
	Message string
}

func NewAuthenticationFailedErr

func NewAuthenticationFailedErr() RuntimeError

func NewForeignKeyConstraintError

func NewForeignKeyConstraintError(column string) 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 (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