Documentation
¶
Index ¶
- func Always(value any) bond.AlwaysProp
- func Back(w http.ResponseWriter, r *http.Request)
- func Defer(fn func() (any, error), group ...string) bond.DeferredProp
- func Error(w http.ResponseWriter, r *http.Request, message string, url string)
- func FormError(w http.ResponseWriter, r *http.Request, errors map[string]interface{})
- func Initialize(config Config) error
- func Lazy(fn func() (any, error)) bond.LazyProp
- func LazyProp(value any) bond.OptionalProp
- func LoadTemplateFromFile(path string) (string, error)
- func Location(w http.ResponseWriter, r *http.Request, url string)
- func Middleware() router.MiddlewareFunc
- func Optional(fn func() (any, error)) bond.OptionalProp
- func Redirect(w http.ResponseWriter, r *http.Request, url string)
- func Render(w http.ResponseWriter, r *http.Request, component string, props ...Props) error
- func SetGlobalEngine(e *Engine)
- func SetSharePropsFunc(fn SharePropsFunc)
- func Share(key string, value interface{})
- func ShareFunc(key string, fn func(r *http.Request) (interface{}, error))
- func ShareMultiple(props Props)
- func Success(w http.ResponseWriter, r *http.Request, message string, url string)
- func WithErrors(w http.ResponseWriter, r *http.Request, component string, props Props, ...) error
- func WithFlash(w http.ResponseWriter, r *http.Request, component string, props Props, ...) error
- type Config
- type Engine
- func (e *Engine) Back(w http.ResponseWriter, r *http.Request)
- func (e *Engine) Bond() *bond.Bond
- func (e *Engine) Location(w http.ResponseWriter, r *http.Request, url string)
- func (e *Engine) Middleware() router.MiddlewareFunc
- func (e *Engine) Redirect(w http.ResponseWriter, r *http.Request, url string)
- func (e *Engine) Render(w http.ResponseWriter, r *http.Request, component string, props ...Props) error
- func (e *Engine) SetSharePropsFunc(fn SharePropsFunc)
- func (e *Engine) Share(key string, value interface{})
- func (e *Engine) ShareFunc(key string, fn func(r *http.Request) (interface{}, error))
- type Props
- type SharePropsFunc
- type SimpleFlashProvider
- type SimpleValidationProvider
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Always ¶
func Always(value any) bond.AlwaysProp
Always creates a prop that always loads (even on partial reloads)
func Defer ¶
func Defer(fn func() (any, error), group ...string) bond.DeferredProp
Defer creates a deferred prop that loads after the initial response
func FormError ¶
func FormError(w http.ResponseWriter, r *http.Request, errors map[string]interface{})
FormError redirects back with form validation errors
func Initialize ¶
func LazyProp ¶
func LazyProp(value any) bond.OptionalProp
LazyProp creates a lazy prop that only evaluates when needed Note: This is an alias for Optional for backwards compatibility
func LoadTemplateFromFile ¶
LoadTemplateFromFile loads the root template from a file
func Middleware ¶
func Middleware() router.MiddlewareFunc
func Optional ¶
func Optional(fn func() (any, error)) bond.OptionalProp
Optional creates an optional prop (alias for Lazy)
func SetGlobalEngine ¶ added in v0.9.5
func SetGlobalEngine(e *Engine)
SetGlobalEngine sets the global view engine and wires its bond instance into the bond global. Used by velocity.Default() to wire the App's view engine into the global.
func SetSharePropsFunc ¶
func SetSharePropsFunc(fn SharePropsFunc)
func ShareMultiple ¶
func ShareMultiple(props Props)
func WithErrors ¶
func WithErrors(w http.ResponseWriter, r *http.Request, component string, props Props, errors map[string]interface{}) error
WithErrors renders with validation errors merged into props
Types ¶
type Config ¶
type Config struct {
RootTemplate string
Version string
SSREnabled bool // Future: SSR support
SSRURL string
}
Config holds view configuration
type Engine ¶ added in v0.9.5
type Engine struct {
// contains filtered or unexported fields
}
Engine wraps a bond.Bond instance and provides the view layer API.
func (*Engine) Back ¶ added in v0.9.5
func (e *Engine) Back(w http.ResponseWriter, r *http.Request)
Back redirects back (SPA navigation).
func (*Engine) Location ¶ added in v0.9.5
Location performs an external redirect (forces full page load).
func (*Engine) Middleware ¶ added in v0.9.5
func (e *Engine) Middleware() router.MiddlewareFunc
Middleware returns the Inertia middleware as a router.MiddlewareFunc.
func (*Engine) Redirect ¶ added in v0.9.5
Redirect performs an SPA redirect (for internal navigation).
func (*Engine) Render ¶ added in v0.9.5
func (e *Engine) Render(w http.ResponseWriter, r *http.Request, component string, props ...Props) error
Render renders a component with optional props.
func (*Engine) SetSharePropsFunc ¶ added in v0.9.5
func (e *Engine) SetSharePropsFunc(fn SharePropsFunc)
SetSharePropsFunc sets a function that returns props to be shared per request.
type SharePropsFunc ¶
SharePropsFunc is a function that returns props to be shared per request
type SimpleFlashProvider ¶
type SimpleFlashProvider struct {
// contains filtered or unexported fields
}
SimpleFlashProvider is a basic flash message provider
func NewSimpleFlashProvider ¶
func NewSimpleFlashProvider() *SimpleFlashProvider
NewSimpleFlashProvider creates a new flash provider
func (*SimpleFlashProvider) GetFlashData ¶
func (p *SimpleFlashProvider) GetFlashData(r *http.Request) (map[string]interface{}, error)
GetFlashData returns all flash messages
func (*SimpleFlashProvider) Set ¶
func (p *SimpleFlashProvider) Set(key string, value interface{})
Set sets a flash message
type SimpleValidationProvider ¶
type SimpleValidationProvider struct {
// contains filtered or unexported fields
}
SimpleValidationProvider is a basic validation errors provider
func NewSimpleValidationProvider ¶
func NewSimpleValidationProvider() *SimpleValidationProvider
NewSimpleValidationProvider creates a new validation provider
func (*SimpleValidationProvider) GetOldInput ¶
func (p *SimpleValidationProvider) GetOldInput(r *http.Request) (map[string]interface{}, error)
GetOldInput returns old form input (preserved on validation errors)
func (*SimpleValidationProvider) GetValidationErrors ¶
func (p *SimpleValidationProvider) GetValidationErrors(r *http.Request) (map[string]interface{}, error)
GetValidationErrors returns validation errors
func (*SimpleValidationProvider) Set ¶
func (p *SimpleValidationProvider) Set(errors map[string]interface{})
Set sets validation errors