Documentation
¶
Index ¶
- type Adapter
- type InertiaManager
- func (m *InertiaManager) Always(ctx contractshttp.Context, key string, fn func() any)
- func (m *InertiaManager) ClearHistory(ctx contractshttp.Context)
- func (m *InertiaManager) DeepMerge(ctx contractshttp.Context, key string, fn func() any, matchOn ...string)
- func (m *InertiaManager) Defer(ctx contractshttp.Context, key string, fn func() any, group ...string)
- func (m *InertiaManager) EncryptHistory(ctx contractshttp.Context)
- func (m *InertiaManager) Error(ctx contractshttp.Context, key string, value any)
- func (m *InertiaManager) Flash(ctx contractshttp.Context, data map[string]any)
- func (m *InertiaManager) FlashErrors(ctx contractshttp.Context, errors validation.Errors)
- func (m *InertiaManager) GetAdapter() *Adapter
- func (m *InertiaManager) Location(ctx contractshttp.Context, url string) contractshttp.Response
- func (m *InertiaManager) Merge(ctx contractshttp.Context, key string, fn func() any, matchOn ...string)
- func (m *InertiaManager) Once(ctx contractshttp.Context, key string, fn func() any)
- func (m *InertiaManager) Optional(ctx contractshttp.Context, key string, fn func() any)
- func (m *InertiaManager) Prepend(ctx contractshttp.Context, key string, fn func() any, matchOn ...string)
- func (m *InertiaManager) PreserveFragment(ctx contractshttp.Context)
- func (m *InertiaManager) Prop(ctx contractshttp.Context, key string, value any)
- func (m *InertiaManager) Redirect(ctx contractshttp.Context, url string) contractshttp.Response
- func (m *InertiaManager) Render(ctx contractshttp.Context, component string, props map[string]any) contractshttp.Response
- func (m *InertiaManager) Scroll(ctx contractshttp.Context, key string, prop contracts.ScrollProp)
- func (m *InertiaManager) Share(key string, value any)
- func (m *InertiaManager) ShareFunc(key string, fn func(contractshttp.Context) any)
- func (m *InertiaManager) ShareSession(ctx contractshttp.Context)
- func (m *InertiaManager) URL() string
- func (m *InertiaManager) Version() string
- type ServiceProvider
- type Vite
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Adapter ¶
type Adapter struct {
// contains filtered or unexported fields
}
func NewAdapter ¶
func (*Adapter) CSR ¶
CSR returns the SSR-disabled fallback engine, or nil when SSR is off. It is set once at boot and read-only afterwards.
func (*Adapter) SetCSR ¶
SetCSR registers the SSR-disabled fallback engine used when an SSR render fails.
func (*Adapter) Writer ¶
func (a *Adapter) Writer(ctx contractshttp.Context) stdhttp.ResponseWriter
type InertiaManager ¶
type InertiaManager struct {
// contains filtered or unexported fields
}
InertiaManager is the Goravel-facing implementation of the Inertia protocol, adapting Goravel's http.Context to the underlying petaki/inertia-go engine.
func NewInertiaManager ¶
func NewInertiaManager(adapter *Adapter, url string, version string, flashKeys ...string) *InertiaManager
NewInertiaManager builds a manager. flashKeys overrides the session keys mirrored into props.flash; when omitted it falls back to defaultFlashKeys.
func (*InertiaManager) Always ¶
func (m *InertiaManager) Always(ctx contractshttp.Context, key string, fn func() any)
Always registers a prop included on every response, even on partial reloads.
func (*InertiaManager) ClearHistory ¶
func (m *InertiaManager) ClearHistory(ctx contractshttp.Context)
ClearHistory instructs the client to clear its history state.
func (*InertiaManager) DeepMerge ¶
func (m *InertiaManager) DeepMerge(ctx contractshttp.Context, key string, fn func() any, matchOn ...string)
DeepMerge registers a prop the client deep-merges with existing data.
func (*InertiaManager) Defer ¶
func (m *InertiaManager) Defer(ctx contractshttp.Context, key string, fn func() any, group ...string)
Defer registers a prop evaluated lazily by the client after the initial load.
func (*InertiaManager) EncryptHistory ¶
func (m *InertiaManager) EncryptHistory(ctx contractshttp.Context)
EncryptHistory instructs the client to encrypt its history state.
func (*InertiaManager) Error ¶
func (m *InertiaManager) Error(ctx contractshttp.Context, key string, value any)
Error attaches a single validation error to the response.
func (*InertiaManager) Flash ¶
func (m *InertiaManager) Flash(ctx contractshttp.Context, data map[string]any)
Flash attaches flash data under props.flash, matching the Inertia + Laravel convention where flash is a shared prop read via usePage().props.flash. This keeps flash consistent with props.errors instead of petaki's top-level page.flash.
func (*InertiaManager) FlashErrors ¶
func (m *InertiaManager) FlashErrors(ctx contractshttp.Context, errors validation.Errors)
FlashErrors flattens Goravel validation errors to one message per field and flashes them to the session. Call it before redirecting back from a failed validation; ShareSession then exposes them as props.errors on the next request.
func (*InertiaManager) GetAdapter ¶
func (m *InertiaManager) GetAdapter() *Adapter
GetAdapter returns the underlying Goravel-to-petaki adapter.
func (*InertiaManager) Location ¶
func (m *InertiaManager) Location(ctx contractshttp.Context, url string) contractshttp.Response
Location performs a full-page redirect to an external URL via the Inertia protocol (409 + X-Inertia-Location for Inertia requests, 302 otherwise).
func (*InertiaManager) Merge ¶
func (m *InertiaManager) Merge(ctx contractshttp.Context, key string, fn func() any, matchOn ...string)
Merge registers a prop the client shallow-merges with existing data.
func (*InertiaManager) Once ¶
func (m *InertiaManager) Once(ctx contractshttp.Context, key string, fn func() any)
Once registers a prop sent only once and then cached by the client.
func (*InertiaManager) Optional ¶
func (m *InertiaManager) Optional(ctx contractshttp.Context, key string, fn func() any)
Optional registers a prop only evaluated when explicitly requested (partial reload).
func (*InertiaManager) Prepend ¶
func (m *InertiaManager) Prepend(ctx contractshttp.Context, key string, fn func() any, matchOn ...string)
Prepend registers a merge prop whose values are prepended instead of appended.
func (*InertiaManager) PreserveFragment ¶
func (m *InertiaManager) PreserveFragment(ctx contractshttp.Context)
PreserveFragment keeps the URL fragment across the visit.
func (*InertiaManager) Prop ¶
func (m *InertiaManager) Prop(ctx contractshttp.Context, key string, value any)
Prop sets an eagerly-evaluated per-request prop.
func (*InertiaManager) Redirect ¶
func (m *InertiaManager) Redirect(ctx contractshttp.Context, url string) contractshttp.Response
Redirect issues an Inertia-aware internal redirect, picking 303 for mutating requests so the client re-fetches the target with a GET.
func (*InertiaManager) Render ¶
func (m *InertiaManager) Render(ctx contractshttp.Context, component string, props map[string]any) contractshttp.Response
Render returns a response that renders the given component with props, merging shared props and threading any per-request v3 props from the context.
func (*InertiaManager) Scroll ¶
func (m *InertiaManager) Scroll(ctx contractshttp.Context, key string, prop contracts.ScrollProp)
Scroll registers an infinite-scroll/pagination prop.
func (*InertiaManager) Share ¶
func (m *InertiaManager) Share(key string, value any)
Share registers a prop included on every Inertia response for all requests. It fans out to the CSR fallback engine too so fallback renders carry the same shared props.
func (*InertiaManager) ShareFunc ¶
func (m *InertiaManager) ShareFunc(key string, fn func(contractshttp.Context) any)
ShareFunc registers a shared prop resolved per request from the context.
func (*InertiaManager) ShareSession ¶
func (m *InertiaManager) ShareSession(ctx contractshttp.Context)
ShareSession mirrors flash messages and validation errors stored in the session into the Inertia props for this request. It runs in the middleware before the handler, so both the initial HTML load and X-Inertia visits pick them up: props.flash for the configured flash keys, props.errors for validation errors.
func (*InertiaManager) URL ¶
func (m *InertiaManager) URL() string
URL returns the configured application base URL.
func (*InertiaManager) Version ¶
func (m *InertiaManager) Version() string
Version returns the configured asset version used for the version check.
type ServiceProvider ¶ added in v0.2.0
type ServiceProvider struct {
}
ServiceProvider registers and boots the Inertia singleton and facade.
Registered in a Goravel application via package:install (which wires it into bootstrap/providers.go automatically) or manually:
import goravelinertia "github.com/eddyjj92/goravel-inertia"
&goravelinertia.ServiceProvider{}
func (*ServiceProvider) Boot ¶ added in v0.2.0
func (p *ServiceProvider) Boot(app foundation.Application)
Boot resolves the manager, registers default shared props, and exposes the facade.
func (*ServiceProvider) Register ¶ added in v0.2.0
func (p *ServiceProvider) Register(app foundation.Application)
Register binds the Inertia manager as the "goravel.inertia" singleton.
type Vite ¶
type Vite struct {
// contains filtered or unexported fields
}
Vite resolves asset tags for Inertia's root template, mirroring the Laravel @vite directive: it serves assets from the running dev server when one is active, otherwise from the hashed files listed in the build manifest.
func NewVite ¶
NewVite builds a Vite helper. Empty arguments fall back to Laravel-compatible defaults: publicPath "public", buildDir "build", hotFile "public/hot".
func (*Vite) TemplateFunc ¶
TemplateFunc returns the function registered as {{ vite "entry" ... }}.
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
Package console provides the artisan commands shipped with goravel-inertia.
|
Package console provides the artisan commands shipped with goravel-inertia. |
|
Command setup wires goravel-inertia into a Goravel application when installed via `./artisan package:install github.com/eddyjj92/goravel-inertia`.
|
Command setup wires goravel-inertia into a Goravel application when installed via `./artisan package:install github.com/eddyjj92/goravel-inertia`. |