core

package
v0.1.3 Latest Latest
Warning

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

Go to latest
Published: Jul 3, 2026 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MIMETextPlain       = "text/plain; charset=utf-8"
	MIMETextHTML        = "text/html; charset=utf-8"
	MIMEApplicationJSON = "application/json; charset=utf-8"
	MIMEApplicationXML  = "application/xml; charset=utf-8"
	MIMEOctetStream     = "application/octet-stream"
	MIMEFormURLEncoded  = "application/x-www-form-urlencoded"
	MIMEMultipartForm   = "multipart/form-data"
)

Variables

This section is empty.

Functions

func Cast

func Cast[T any](value any, defaults ...T) T

Cast converts value to T and returns fallback or zero value when conversion fails.

func CastOK

func CastOK[T any](value any) (T, bool)

CastOK converts value to T and reports whether conversion succeeded.

func CloneStringMap

func CloneStringMap(input map[string]any) map[string]any

CloneStringMap deep-copies a map[string]any whose nested maps use map[string]any.

func ColorEnabled added in v0.1.1

func ColorEnabled(writer io.Writer) bool

ColorEnabled reports whether ANSI colors should be emitted for writer.

func DefaultContext

func DefaultContext() context.Context

DefaultContext returns Runa's fallback root context.

func In

func In(t time.Time) time.Time

In converts t to the application timezone.

func Location

func Location() *time.Location

Location returns the application timezone.

func NormalizeContext

func NormalizeContext(ctx context.Context) context.Context

NormalizeContext returns DefaultContext when ctx is nil.

func Now

func Now() time.Time

Now returns the current wall-clock time in the application timezone.

func Parse

func Parse(layout string, value string) (time.Time, error)

Parse parses a time value in the application timezone.

func SetClock

func SetClock(clock Clock)

SetClock overrides the application clock. Passing nil restores the system clock.

func SetLocation

func SetLocation(location *time.Location)

SetLocation sets the application timezone.

func TypeName

func TypeName(value reflect.Type) string

TypeName returns a stable type name string.

func TypeOf

func TypeOf[T any]() reflect.Type

TypeOf returns the reflect type of T.

Types

type Clock

type Clock interface {
	Now() time.Time
}

Clock returns the current time.

type Empty

type Empty struct{}

Empty represents an empty request or response body.

type FixedClock

type FixedClock time.Time

FixedClock always returns the same time.

func (FixedClock) Now

func (clock FixedClock) Now() time.Time

Now returns the fixed time.

type JSONRaw

type JSONRaw []byte

JSONRaw stores raw JSON bytes.

func (JSONRaw) Bytes

func (raw JSONRaw) Bytes() []byte

Bytes returns raw JSON bytes.

func (JSONRaw) Map

func (raw JSONRaw) Map() Map

Map decodes raw JSON into Map.

func (JSONRaw) MarshalJSON

func (raw JSONRaw) MarshalJSON() ([]byte, error)

MarshalJSON returns raw JSON bytes.

func (JSONRaw) String

func (raw JSONRaw) String() string

String returns raw JSON as string.

func (*JSONRaw) UnmarshalJSON

func (raw *JSONRaw) UnmarshalJSON(data []byte) error

UnmarshalJSON keeps the original JSON subtree bytes.

type ListMeta

type ListMeta interface {
	ListMeta() Map
}

ListMeta is the common list metadata contract.

type Map

type Map map[string]any

Map is Runa's common map type used for metadata, JSON payloads, and options.

func CloneMap

func CloneMap(input Map) Map

CloneMap copies a Runa map.

type Page

type Page[T any] struct {
	Items []T `json:"items"`
	Meta  Map `json:"meta,omitempty"`
}

Page stores a paginated response body.

type PageMeta

type PageMeta struct {
	Page     int `json:"page"`
	PageSize int `json:"page_size"`
	Total    int `json:"total"`
}

PageMeta stores offset pagination output metadata.

func (PageMeta) ListMeta

func (meta PageMeta) ListMeta() Map

ListMeta returns page metadata as a map.

type PageRequest

type PageRequest struct {
	Page     int
	PageSize int
	Offset   int
	Limit    int
}

PageRequest stores offset pagination input.

type Scroll

type Scroll[T any] struct {
	Items []T `json:"items"`
	Meta  Map `json:"meta,omitempty"`
}

Scroll stores a cursor response body.

type ScrollMeta

type ScrollMeta struct {
	Cursor string `json:"cursor,omitempty"`
	Limit  int    `json:"limit"`
	Next   string `json:"next,omitempty"`
}

ScrollMeta stores cursor pagination output metadata.

func (ScrollMeta) ListMeta

func (meta ScrollMeta) ListMeta() Map

ListMeta returns scroll metadata as a map.

type ScrollRequest

type ScrollRequest struct {
	Cursor string
	Limit  int
}

ScrollRequest stores cursor pagination input.

type Stream

type Stream struct {
	Reader      io.Reader
	Size        int64
	ContentType string
}

Stream describes a raw request body stream.

type UploadFile

type UploadFile struct {
	Filename    string
	Size        int64
	ContentType string
	Header      *multipart.FileHeader
}

UploadFile describes an uploaded multipart file.

func (UploadFile) Open

func (file UploadFile) Open() (multipart.File, error)

Open opens the uploaded file.

type ViewBody

type ViewBody struct {
	Name string
	Data any
	View string
}

ViewBody represents a template response body.

func RenderView

func RenderView(name string, data any, views ...string) ViewBody

RenderView creates a template response body.

Jump to

Keyboard shortcuts

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