pneuma

package module
v0.0.0-...-109165f Latest Latest
Warning

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

Go to latest
Published: Oct 22, 2024 License: CC0-1.0, Unlicense Imports: 27 Imported by: 0

README

Documentation

Index

Constants

View Source
const PackageName string = "github.com/letschurch/pneuma"

Variables

This section is empty.

Functions

func ApplyConfiguration

func ApplyConfiguration[T any](t *T, opts ...Configurator[T]) error

func GetFuncName

func GetFuncName(fn any) string

func NewApp

func NewApp(opts ...Configurator[app]) (*app, error)

NewApp creates a new pneuma app.

Types

type Configurator

type Configurator[T any] func(options *T) error

Configurator is a generic function for implementing the functional options pattern.

func If

func If[T any](condition bool, opt ...Configurator[T]) Configurator[T]

If makes a Configurator apply only if a given boolean is true.

func WithDev

func WithDev() Configurator[app]

WithDev sets up a pneuma app for development

func WithDevCmd

func WithDevCmd(cmd string) Configurator[app]

WithDevCmd sets the development command of a pneuma app (defaults to "go run .")

func WithHost

func WithHost(host string) Configurator[app]

WithHost sets the host a pneuma app listens on (defaults to HOST environment variable or 127.0.0.1).

func WithId

func WithId(id string) Configurator[Island]

WithId assigns an id to a Island.

func WithIsland

func WithIsland[C PneumaIsland]() Configurator[app]

WithIsland adds an Island to a pneuma app.

func WithPort

func WithPort(port int) Configurator[app]

WithPort sets the port a pneuma app listens on (defaults to PORT environment variable or any unused port).

func WithPrefix

func WithPrefix(prefix string) Configurator[app]

WithPrefix sets the prefix where pneuma internals are served from (defaults to "_pneuma")

func WithProvider

func WithProvider(factory any) Configurator[app]

WithProvider adds a provider to a pneuma app. See dig.Container.Provide.

func WithRoute

func WithRoute(pattern string, handler any) Configurator[app]

WithRoute registers a route with a pneuma app.

func WithRouteScopeProvider

func WithRouteScopeProvider(factory any) Configurator[app]

WithRouteScopeProvider adds a provider that lazily executes, scoped to each request.

type DevSlogHandler

type DevSlogHandler struct {
	Level slog.Level
	Group string
	Attrs []slog.Attr
}

func NewDevSlogHandler

func NewDevSlogHandler() *DevSlogHandler

func (*DevSlogHandler) Enabled

func (h *DevSlogHandler) Enabled(_ context.Context, level slog.Level) bool

func (*DevSlogHandler) Handle

func (h *DevSlogHandler) Handle(ctx context.Context, r slog.Record) error

func (*DevSlogHandler) WithAttrs

func (h *DevSlogHandler) WithAttrs(attrs []slog.Attr) slog.Handler

func (*DevSlogHandler) WithGroup

func (h *DevSlogHandler) WithGroup(name string) slog.Handler

type In

type In = dig.In

type Island

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

Island represents a dynamic component on a web page.

func (*Island) Render

func (r *Island) Render(w io.Writer) error

Implement the Node interface (also from gomponents) so [Island]s can be used as gomponent [Node]s.

func (*Island) String

func (r *Island) String() string

Implement the Stringer interface so [Island]s can be rendered as strings.

func (*Island) Write

func (r *Island) Write(w io.Writer) error

Write writes a Island to an io.Writer.

type Node

type Node interface {
	Render(w io.Writer) error
}

Node is a DOM node that can Render itself to an io.Writer. It is compatible with Node from gomponents.

type Out

type Out = dig.Out

type PneumaContext

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

func (*PneumaContext) Deadline

func (ctx *PneumaContext) Deadline() (deadline time.Time, ok bool)

func (*PneumaContext) Done

func (ctx *PneumaContext) Done() <-chan struct{}

func (*PneumaContext) Err

func (ctx *PneumaContext) Err() error

func (*PneumaContext) HeadHtml

func (ctx *PneumaContext) HeadHtml() string

func (*PneumaContext) Invoke

func (ctx *PneumaContext) Invoke(f any) error

func (*PneumaContext) Render

func (ctx *PneumaContext) Render(island PneumaIsland, node Node, opts ...Configurator[Island]) *Island

Render makes an Island from a Node. This can be used to implement the PneumaIsland interface.

func (*PneumaContext) StringIsland

func (ctx *PneumaContext) StringIsland(c PneumaIsland, s string, opts ...Configurator[Island]) *Island

StringIsland creates a Island from a [string]. This can be used to implement the PneumaIsland interface.

func (*PneumaContext) Value

func (ctx *PneumaContext) Value(key any) any

type PneumaIsland

type PneumaIsland interface {
	Render(ctx *PneumaContext) *Island
}

PneumaIsland is an interface that defines a component that can be rendered as an dynamic portion of a page. This is intended to be implemented by consumers of pneuma. Types that implement PneumaIsland should be able to be marshaleld to and from JSON.

type PublicError

type PublicError interface {
	Public() string
}

type StringIsland

type StringIsland string

StringIsland is a [string] that implements Node.

func (StringIsland) Render

func (s StringIsland) Render(w io.Writer) error

Render makes StringIsland implement Node.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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