core

package module
v0.0.0-...-8dc6373 Latest Latest
Warning

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

Go to latest
Published: Feb 25, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrForbidden = errors.New("forbidden")
View Source
var ErrNotFound = errors.New("not found")
View Source
var ErrUnauthorized = errors.New("unauthorized")

Functions

func PutPrincipal

func PutPrincipal(ctx context.Context, op Principal) context.Context

PutPrincipal stores a Principal in the context.

Types

type Action

type Action string

type AllowAll

type AllowAll struct{}

AllowAll is a Guard that permits all actions.

func (AllowAll) Check

type AllowNone

type AllowNone struct{}

AllowNone is a Guard that denies all actions.

func (AllowNone) Check

type Clock

type Clock interface {
	Now() time.Time
}

type Guard

type Guard interface {
	Check(context.Context, Action, Path) error
}

type ID

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

func NewID

func NewID() ID

func ParseID

func ParseID(s string) (ID, error)

ParseID parses a string into an ID

func (ID) Compare

func (id ID) Compare(other ID) int

Compare returns -1 if id < other, 0 if id == other, 1 if id > other. IDs are compared lexicographically, which matches byte-order comparison because the encoding preserves sort order.

func (ID) Equal

func (id ID) Equal(other ID) bool

Equal returns true if this ID equals the other ID

func (ID) IsZero

func (id ID) IsZero() bool

IsZero returns true if the ID is the zero value

func (ID) MarshalBinary

func (id ID) MarshalBinary() ([]byte, error)

func (ID) MarshalText

func (id ID) MarshalText() ([]byte, error)

func (*ID) Scan

func (id *ID) Scan(src any) error

Scan implements sql.Scanner for SQL retrieval (reads from text)

func (ID) String

func (id ID) String() string

func (*ID) UnmarshalBinary

func (id *ID) UnmarshalBinary(data []byte) error

func (*ID) UnmarshalText

func (id *ID) UnmarshalText(data []byte) error

func (ID) Value

func (id ID) Value() (driver.Value, error)

Value implements driver.Valuer for SQL storage (stores as text)

type Page

type Page[T any] struct {
	Items  []T
	Cursor string
}

type PageReq

type PageReq struct {
	Limit  int
	Cursor string
}

type Path

type Path string

type Principal

type Principal interface {
	PrincipalID() ID
}

func Anonymous

func Anonymous() Principal

func GetPrincipal

func GetPrincipal(ctx context.Context) Principal

GetPrincipal retrieves a core.Op from the context. If not found, returns a zero value (anonymous) principal.

Source Files

  • clock.go
  • core.go
  • guard.go
  • id.go
  • principal.go

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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