Documentation ¶
Index ¶
- Constants
- Variables
- func Middleware(echo *echo.Echo) echo.MiddlewareFunc
- func MiddlewareWithConfig(config MiddlewareConfig) echo.MiddlewareFunc
- type Inertia
- func (i *Inertia) GetShared(c echo.Context, key string) (interface{}, bool)
- func (i *Inertia) GetVersion() string
- func (i *Inertia) Render(w io.Writer, name string, data interface{}, c echo.Context) error
- func (i *Inertia) SetVersion(version string)
- func (i *Inertia) Share(c echo.Context, key string, value interface{})
- func (i *Inertia) Shared(c echo.Context) map[string]interface{}
- func (i *Inertia) Shares(c echo.Context, values map[string]interface{})
- func (i *Inertia) Version(version func() string)
- type InertiaConfig
- type MiddlewareConfig
- type Response
Constants ¶
const ( HeaderPrefix = "X-Inertia" HeaderVersion = HeaderPrefix + "-Version" HeaderLocation = HeaderPrefix + "-Location" HeaderPartialData = HeaderPrefix + "-Partial-Data" )
The Base "X-Inertia" header prefixes
Variables ¶
var DefaultHTTPErrorHandler = func(err error, c echo.Context) { code := http.StatusInternalServerError if he, ok := err.(*echo.HTTPError); ok { code = he.Code } _ = c.Render(code, "Error", map[string]interface{}{ "status": code, }) }
DefaultHTTPErrorHandler is the default error handler for Inertia.
Functions ¶
func Middleware ¶
func Middleware(echo *echo.Echo) echo.MiddlewareFunc
Middleware creates a default Inertia middleware for the given Echo instance.
func MiddlewareWithConfig ¶
func MiddlewareWithConfig(config MiddlewareConfig) echo.MiddlewareFunc
MiddlewareWithConfig creates an Inertia middleware with a specific configuration.
Types ¶
type Inertia ¶
type Inertia struct {
// contains filtered or unexported fields
}
Inertia is a struct representing the Inertia handler.
func NewInertia ¶
func NewInertia(echo *echo.Echo) (i *Inertia)
Instance a new Inertia Handler with a default config
func NewInertiaWithConfig ¶
func NewInertiaWithConfig(config InertiaConfig) (i *Inertia)
Instance a new Inertia Handler with a configuration
func (*Inertia) GetVersion ¶
type InertiaConfig ¶
type InertiaConfig struct { Echo *echo.Echo PublicPath string TemplatesPath string RootView string TemplateFuncMap template.FuncMap HTTPErrorHandler echo.HTTPErrorHandler RequestIDConfig middleware.RequestIDConfig }
InertiaConfig holds the configuration for the Inertia handler.
func NewDefaultInertiaConfig ¶
func NewDefaultInertiaConfig(e *echo.Echo) (i InertiaConfig)
Create a default Inertia Config to use without the hassle of setting up everything
type MiddlewareConfig ¶
type MiddlewareConfig struct { Inertia *Inertia // Reference to the Inertia instance Skipper middleware.Skipper // Skipper function to conditionally skip the middleware }
MiddlewareConfig holds configuration options for the Inertia middleware.
type Response ¶
type Response struct {
// contains filtered or unexported fields
}
Response represents an Inertia response.
func NewResponse ¶
func NewResponse(component string, props map[string]interface{}, rootView string, version string) Response
NewResponse creates a new Inertia response.
func (Response) ToResponse ¶
ToResponse sends the Inertia response to the client.
func (Response) WithViewData ¶
WithViewData adds a key-value pair to the response's view data.