Documentation ¶
Index ¶
- Constants
- func ApplyConfiguration[T any](t *T, opts ...Configurator[T]) error
- func GetFuncName(fn any) string
- func NewApp(opts ...Configurator[app]) (*app, error)
- type Configurator
- func If[T any](condition bool, opt ...Configurator[T]) Configurator[T]
- func WithDev() Configurator[app]
- func WithDevCmd(cmd string) Configurator[app]
- func WithHost(host string) Configurator[app]
- func WithId(id string) Configurator[Island]
- func WithIsland[C PneumaIsland]() Configurator[app]
- func WithPort(port int) Configurator[app]
- func WithPrefix(prefix string) Configurator[app]
- func WithProvider(factory any) Configurator[app]
- func WithRoute(pattern string, handler any) Configurator[app]
- func WithRouteScopeProvider(factory any) Configurator[app]
- type DevSlogHandler
- type In
- type Island
- type Node
- type Out
- type PneumaContext
- func (ctx *PneumaContext) Deadline() (deadline time.Time, ok bool)
- func (ctx *PneumaContext) Done() <-chan struct{}
- func (ctx *PneumaContext) Err() error
- func (ctx *PneumaContext) HeadHtml() string
- func (ctx *PneumaContext) Invoke(f any) error
- func (ctx *PneumaContext) Render(island PneumaIsland, node Node, opts ...Configurator[Island]) *Island
- func (ctx *PneumaContext) StringIsland(c PneumaIsland, s string, opts ...Configurator[Island]) *Island
- func (ctx *PneumaContext) Value(key any) any
- type PneumaIsland
- type PublicError
- type StringIsland
Constants ¶
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 ¶
Types ¶
type Configurator ¶
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 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 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 ¶
func NewDevSlogHandler ¶
func NewDevSlogHandler() *DevSlogHandler
type Island ¶
type Island struct {
// contains filtered or unexported fields
}
Island represents a dynamic component on a web page.
func (*Island) Render ¶
Implement the Node interface (also from gomponents) so [Island]s can be used as gomponent [Node]s.
type Node ¶
Node is a DOM node that can Render itself to an io.Writer. It is compatible with Node from gomponents.
type PneumaContext ¶
type PneumaContext struct {
// contains filtered or unexported fields
}
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.