flamigo

package
v0.0.1-alpha.4 Latest Latest
Warning

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

Go to latest
Published: Sep 28, 2025 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (
	TypeActorServer = "backend"
)

Variables

View Source
var (
	ErrNoUserActor      = errors.New("actor is not a user actor")
	ErrNotAuthenticated = errors.New("actor is not authenticated")
	ErrNoPermission     = errors.New("actor does not have permission")
	ErrAuthenticated    = errors.New("actor is authenticated")
	ErrInvalidActorType = errors.New("actor does not fullfill the required type")
)
View Source
var (
	ErrorNotAuthorized = errors.New("not authorized")
)

Functions

func NewHashId

func NewHashId(id string) string

func NewHashSeed

func NewHashSeed(id string) int64

func NewRandomID

func NewRandomID() string

func RequireActorWithClaims

func RequireActorWithClaims[T Actor](ctx Context, opts ...ActorClaimValidator) (parsedActor T, err error)

func VerifyActorClaims

func VerifyActorClaims(ctx Context, opts ...ActorClaimValidator) error

Types

type Actor

type Actor interface {
	Type() string
}

func NewServerActor

func NewServerActor(interfaceName string) Actor

type ActorClaimValidator

type ActorClaimValidator = func(ctx context.Context, actor Actor) error

func IsActorOfType

func IsActorOfType(interfaceName string) ActorClaimValidator

func IsServer

func IsServer() ActorClaimValidator

func OfType

func OfType(requiredType string) ActorClaimValidator

type Context

type Context interface {
	context.Context
	Actor() Actor
}

func NewContext

func NewContext(ctx context.Context, actor Actor) Context

type Error

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

func NewError

func NewError(message string, opts ...ErrorOpt) *Error

func WrapError

func WrapError(message string, err error, opts ...ErrorOpt) *Error

func (*Error) Error

func (e *Error) Error() string

Error implements the error interface

func (*Error) PublicError

func (e *Error) PublicError() string

PublicError returns the public error message If no public message is set, it returns the inner error message If no inner error is set, it returns "unknown error"

func (*Error) StatusCode

func (e *Error) StatusCode() int

func (*Error) Unwrap

func (e *Error) Unwrap() error

Unwraps the internal error

If there is no inner error, it returns nil

type ErrorOpt

type ErrorOpt = func(e *Error)

func Public

func Public(message string) ErrorOpt

Public sets the public message

func StatusCode

func StatusCode(code int) ErrorOpt

StatusCode sets the status code

func WithPublicResponse

func WithPublicResponse(message string, code ...int) ErrorOpt

Sets the public message and status code

type PublicError

type PublicError interface {
	PublicError() string
	StatusCode() int
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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