goinertia

package module
v0.10.1 Latest Latest
Warning

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

Go to latest
Published: Jun 4, 2026 License: MIT Imports: 23 Imported by: 0

README

goinertia

Go Reference Go Report Card Go

The Fiber-first adapter for Inertia.js.

goinertia allows you to build modern single-page apps using Vue.js, React, or Svelte while keeping routing and controllers in your Go (Fiber) backend. It strictly adheres to the Inertia.js protocol.

Visit:

Features

  • ⚡️ Fiber Native: Built specifically for the Fiber web framework (v3).
  • 🔄 Full Protocol Support: Implements the complete Inertia.js spec.
    • Asset Versioning: Auto-reloads assets when versions change.
    • Partial Reloads: Only fetch the data you need.
    • Lazy / Deferred / Once: Compute expensive props only when requested.
    • Merge & Scroll Props: Built-in support for v2 merge and infinite scroll metadata.
    • Shared Data: Global props (like "auth.user") available to all pages.
  • 🛡️ Validation & Flash: Built-in helpers for form validation errors and flash messages.
  • 🚀 Server-Side Rendering (SSR): Native support for rendering initial HTML on the server.
  • 🔒 CSRF Protection: Hooks for CSRF token injection and verification.
  • 🐛 Error Handling: Customizable error pages and unified error handling middleware.
  • 🛠 Developer Experience:
    • WithDevMode() for hot-reloading templates and assets.
    • Fail-fast validation at startup (NewWithValidation).

Installation

go get github.com/assurrussa/goinertia

Quick Start

Here is a minimal example showing how to set up the Inertia middleware and render a page.

package main

import (
	"github.com/gofiber/fiber/v3"
	"github.com/assurrussa/goinertia"
)

func main() {
	// 1. Initialize Inertia
	inertiaManager, err := goinertia.NewWithValidation("http://localhost:3000",
		goinertia.WithAssetVersion("v1"),
		goinertia.WithSharedProps(map[string]any{
			"appName": "My App",
		}),
		// goinertia.WithDevMode(), // Use in development to enable hot-reloading
	)
	if err != nil {
		panic(err)
	}

	// 2. Register Middleware
	app := fiber.New(fiber.Config{ErrorHandler: inertiaManager.MiddlewareErrorListener()})
	// Handles Inertia requests, asset versioning, and validation redirects
	app.Use(inertiaManager.Middleware())

	// 3. Define Routes
	app.Get("/", func(c fiber.Ctx) error {
		// Render a Vue/React component named "Home"
		return inertiaManager.Render(c, "Home", map[string]any{
			"user": "John Doe",
		})
	})

	app.Listen(":3000")
}

Core Concepts

Rendering Pages

Use the Render method to return an Inertia response. If it's an XHR request, it returns JSON; otherwise, it renders the root HTML template.

inertiaManager.Render(ctx, "Dashboard/Index", map[string]any{
"stats": statsData,
})
Flash Messages & Validation

goinertia provides helpers to seamlessly pass data to the client, especially after form submissions.

Note: Requires WithSessionStore to be configured.

// In your controller
if err := validate(form); err != nil {
inertiaManager.WithFlashError(ctx, "Something went wrong.")
inertiaManager.WithError(ctx, "email", "Email is already taken.")
return inertiaManager.RedirectBack(ctx)
}

inertiaManager.WithFlashSuccess(ctx, "Profile updated!")
return inertiaManager.Redirect(ctx, "/profile")
Lazy Evaluation

Optimize performance by wrapping expensive data in WithLazyProp. These are only executed if the client explicitly requests them via a partial reload.

inertiaManager.WithLazyProp(ctx, "heavyData", func (c context.Context) (any, error) {
return heavyDatabaseQuery(), nil
})
Server-Side Rendering (SSR)

Enable SSR to improve SEO and initial load performance. goinertia communicates with a Node.js process (the Inertia SSR server) to render the page.

inertiaManager := goinertia.Must(goinertia.NewWithValidation(url,
goinertia.WithSSRConfig(goinertia.SSRConfig{
URL:             "http://127.0.0.1:13714/render", // or goinertia.DefaultSSRURL,
Timeout:         3 * time.Second,
CacheTTL:        5 * time.Minute,
CacheMaxEntries: 1024,
MaxRetries:      2,
RetryDelay:      50 * time.Millisecond,
RetryStatuses:   []int{http.StatusTooManyRequests, http.StatusServiceUnavailable},
// DisableRetries:  true,
// SSRClient:       createClient...,
}),
))

Protocol Coverage (Inertia)

Supported:

  • Core headers: X-Inertia, X-Inertia-Version, X-Inertia-Location, Vary: X-Inertia.
  • Partial reloads: X-Inertia-Partial-Component, X-Inertia-Partial-Data, X-Inertia-Partial-Except.
  • Partial control: X-Inertia-Reset, X-Inertia-Error-Bag, X-Inertia-Except-Once-Props, X-Inertia-Infinite-Scroll-Merge-Intent.
  • Page object v2 fields: deferredProps, mergeProps, prependProps, deepMergeProps, matchPropsOn, scrollProps, onceProps, plus encryptHistory/clearHistory.
  • Redirect semantics: internal redirects (302/303) and external redirects (409 + X-Inertia-Location).
  • errors always included (empty object by default).
  • Precognition flow (Precognition, Precognition-Validate-Only, Precognition-Success, Vary: Precognition).
  • History helpers: WithEncryptHistory / WithClearHistory.
  • Cache-Control: no-cache echo for reload requests.

Documentation

Comprehensive documentation is available in the docs/ directory:

Examples

Check the examples/ directory for fully functional sample applications:

License

MIT

Documentation

Index

Constants

View Source
const (
	// ContextKeyProps key.
	ContextKeyProps = contextKey("props")
	// ContextKeyViewData key.
	ContextKeyViewData = contextKey("viewData")
	// ContextKeyPageMeta key.
	ContextKeyPageMeta = contextKey("pageMeta")
)

Context.

View Source
const (
	// HeaderInertia header.
	HeaderInertia = "X-Inertia"
	// HeaderLocation header.
	HeaderLocation = "X-Inertia-Location"
	// HeaderVersion header.
	HeaderVersion = "X-Inertia-Version"
	// HeaderPartialComponent header.
	HeaderPartialComponent = "X-Inertia-Partial-Component"
	// HeaderPartialOnly header.
	HeaderPartialOnly = "X-Inertia-Partial-Data"
	// HeaderPartialExcept header.
	HeaderPartialExcept = "X-Inertia-Partial-Except"
	// HeaderReset header.
	HeaderReset = "X-Inertia-Reset"
	// HeaderErrorBag header.
	HeaderErrorBag = "X-Inertia-Error-Bag"
	// HeaderExceptOnceProps header.
	HeaderExceptOnceProps = "X-Inertia-Except-Once-Props"
	// HeaderInfiniteScrollMergeIntent header.
	HeaderInfiniteScrollMergeIntent = "X-Inertia-Infinite-Scroll-Merge-Intent"
	// HeaderPrecognition header.
	HeaderPrecognition = "Precognition"
	// HeaderPrecognitionValidateOnly header.
	HeaderPrecognitionValidateOnly = "Precognition-Validate-Only"
	// HeaderPrecognitionSuccess header.
	HeaderPrecognitionSuccess = "Precognition-Success"
)

Header.

View Source
const (
	ContextPropsErrors    = "errors"
	ContextPropsOld       = "old"
	ContextPropsFlash     = "flash"
	ContextPropsCSRFToken = "csrf_token"
)

Keys.

View Source
const (
	DefaultSSRURL          = "http://127.0.0.1:13714/render"
	DefaultSSRTimeout      = 3 * time.Second
	DefaultCacheTTL        = 5 * time.Minute
	DefaultCacheMaxEntries = 1024
	DefaultSSRMaxRetries   = 1
	DefaultSSRRetryDelay   = 10 * time.Millisecond
)

Variables

View Source
var (
	// ErrInvalidContextViewData error.
	ErrInvalidContextViewData = errors.New("inertia: could not convert context view data to map")
	// ErrBadSsrStatusCode error.
	ErrBadSsrStatusCode = errors.New("inertia: bad processSSR status code >= 400")
	// ErrBaseURLEmpty error.
	ErrBaseURLEmpty = errors.New("base URL is empty")
)
View Source
var (
	ErrNillable = NewError(500, "inertia: value is nil")
	ErrInternal = NewError(fiber.StatusInternalServerError, utils.StatusMessage(fiber.StatusInternalServerError))
)
View Source
var (
	DefaultCanExpose = func(_ context.Context, _ map[string][]string) bool {
		return false
	}
	DefaultCustomGettingError = func(_ error) *Error {
		return nil
	}
	DefaultCustomErrorDetails = func(appErr *Error, isCanDetails bool) string {
		details := "Something went wrong. Try again later"
		switch {
		case isCanDetails:
			details = appErr.Error()
			if errCause := appErr.Unwrap(); errCause != nil {
				if addDetailErr := errCause.Error(); addDetailErr != details {
					details += ": " + addDetailErr
				}
			}
		default:
			code := appErr.Code
			switch {
			case code == http.StatusBadRequest:
				details = "Bad request"
			case code == fiber.StatusNotFound:
				details = "Page not found"
			case code == fiber.StatusForbidden:
				details = "Permission denied"
			case code == fiber.StatusUnauthorized:
				details = "Unauthorized"
			case code == 419:
				details = "The page expired, please try again"
			case code == fiber.StatusTooManyRequests:
				details = "Too many request"
			case code >= http.StatusInternalServerError:
				details = "Something went wrong. Try again later"
			}
		}

		return details
	}
)

Functions

func IsPrecognition added in v0.9.4

func IsPrecognition(c fiber.Ctx) bool

func Redirect

func Redirect(c fiber.Ctx, url string) error

func RedirectExternal added in v0.9.2

func RedirectExternal(c fiber.Ctx, url string) error

RedirectExternal forces a full page reload for Inertia requests.

Types

type AlwaysProp added in v0.9.2

type AlwaysProp struct {
	Value any
}

AlwaysProp marks a prop as always included, even on partial reloads.

func Always added in v0.9.2

func Always(value any) AlwaysProp

Always wraps a value as an always prop.

type CSRFTokenCheckProvider

type CSRFTokenCheckProvider func(c fiber.Ctx) error

type CSRFTokenProvider

type CSRFTokenProvider func(c fiber.Ctx) (string, error)

type DeferredProp added in v0.9.2

type DeferredProp struct {
	Group string
	Value any
}

DeferredProp marks a prop as deferred (loaded via a follow-up partial reload).

func Defer added in v0.9.2

func Defer(value any, group ...string) DeferredProp

Defer wraps a value as a deferred prop. If group is empty, "default" is used.

type Error

type Error struct {
	Code    int
	Message string
	// contains filtered or unexported fields
}

Error represents an error that occurred while handling a request.

func NewError

func NewError(code int, message string, errs ...error) *Error

NewError creates a new Error instance with an optional message.

func (*Error) CloneValidationError

func (e *Error) CloneValidationError(err *ValidationError) *Error

func (*Error) Error

func (e *Error) Error() string

Error makes it compatible with the `error` interface.

func (*Error) FlashErrors

func (e *Error) FlashErrors() []FlashError

func (*Error) Unwrap

func (e *Error) Unwrap() error

func (*Error) ValidationErrors

func (e *Error) ValidationErrors() ValidationErrors

func (*Error) WithFlashErrors

func (e *Error) WithFlashErrors(errs ...*FlashError) *Error

type FiberSessionAdapter

type FiberSessionAdapter[T FiberSessionStore] struct {
	// contains filtered or unexported fields
}

func NewFiberSessionAdapter

func NewFiberSessionAdapter[T FiberSessionStore](store SessionAdapter[T]) *FiberSessionAdapter[T]

func (*FiberSessionAdapter[T]) Delete

func (f *FiberSessionAdapter[T]) Delete(c fiber.Ctx, key string) error

func (*FiberSessionAdapter[T]) Flash

func (f *FiberSessionAdapter[T]) Flash(c fiber.Ctx, key string, value any) error

func (*FiberSessionAdapter[T]) Get

func (f *FiberSessionAdapter[T]) Get(c fiber.Ctx, key string) (any, error)

func (*FiberSessionAdapter[T]) GetFlash

func (f *FiberSessionAdapter[T]) GetFlash(c fiber.Ctx, key string) (any, error)

func (*FiberSessionAdapter[T]) Set

func (f *FiberSessionAdapter[T]) Set(c fiber.Ctx, key string, value any) error

type FiberSessionStore

type FiberSessionStore interface {
	Set(key, val any)
	Get(key any) any
	Delete(key any)
	Save() error
}

type FlashError

type FlashError struct {
	Level   FlashLevel
	Message string
}

FlashError is a rich error that carries, UI message level and the user-facing message.

func NewFlashError

func NewFlashError(level FlashLevel, userMessage string) *FlashError

NewFlashError creates a FlashError.

func (*FlashError) Error

func (e *FlashError) Error() string

type FlashLevel

type FlashLevel string

FlashLevel is a string enum for flash message level.

const (
	FlashLevelSuccess FlashLevel = "success"
	FlashLevelInfo    FlashLevel = "info"
	FlashLevelWarning FlashLevel = "warning"
	FlashLevelError   FlashLevel = "error"
)

func (FlashLevel) String

func (f FlashLevel) String() string

type Inertia

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

func Must added in v0.9.1

func Must(inr *Inertia, err error) *Inertia

func New

func New(baseURL string, opts ...Option) *Inertia

New init inertia

Example: optsInertia := []inertia.Option{inertia.WithFS(views.Templates)}

	if cfg.Global.IsLocal() {
		optsInertia = []inertia.Option{
			inertia.WithRootTemplate("internal/adminext/views/app.gohtml"),
			inertia.WithRootHotTemplate("internal/adminext/public/hot"),
			inertia.WithFS(nil),
			inertia.WithPublicFS(nil),
         inertia.WithCanExposeDetails(func(c fiber.Ctx) bool {
	          admin := admin_middleware.GetAdminAuth(c)
	          return admin != nil && admin.HasRoles("admin")
         }),
		}
	}
	inertiaManager := inertia.New(cfg.Global.AppDomainURL, optsInertia...)

func NewWithValidation added in v0.9.1

func NewWithValidation(baseURL string, opts ...Option) (*Inertia, error)

func (*Inertia) DisableSSR

func (i *Inertia) DisableSSR()

func (*Inertia) EnableSSR

func (i *Inertia) EnableSSR(cfg SSRConfig)

func (*Inertia) EnableSSRWithDefault

func (i *Inertia) EnableSSRWithDefault()

func (*Inertia) IsSSREnabled

func (i *Inertia) IsSSREnabled() bool

func (*Inertia) Middleware

func (i *Inertia) Middleware() fiber.Handler

Middleware function.

func (*Inertia) MiddlewareErrorListener

func (i *Inertia) MiddlewareErrorListener() fiber.ErrorHandler

func (*Inertia) ParseTemplates added in v0.9.1

func (i *Inertia) ParseTemplates() error

func (*Inertia) Redirect

func (i *Inertia) Redirect(c fiber.Ctx, url string) error

Redirect handles redirects according to Inertia.js protocol.

func (*Inertia) RedirectBack

func (i *Inertia) RedirectBack(c fiber.Ctx) error

RedirectBack redirects back to the previous page after a successful operation.

func (*Inertia) RedirectBackWithErrors

func (i *Inertia) RedirectBackWithErrors(c fiber.Ctx, errors map[string]string) error

RedirectBackWithErrors redirects back with validation errors stored in session.

func (*Inertia) RedirectBackWithValidationErrors

func (i *Inertia) RedirectBackWithValidationErrors(c fiber.Ctx, errors ValidationErrors) error

RedirectBackWithValidationErrors redirects back with multiple validation errors per field.

func (*Inertia) RedirectExternal added in v0.9.2

func (i *Inertia) RedirectExternal(c fiber.Ctx, url string) error

RedirectExternal forces a full page reload for Inertia requests.

func (*Inertia) Render

func (i *Inertia) Render(c fiber.Ctx, component string, props map[string]any) error

func (*Inertia) WithClearHistory added in v0.9.4

func (i *Inertia) WithClearHistory(c fiber.Ctx)

WithClearHistory sets clearHistory metadata for the response.

func (*Inertia) WithEncryptHistory added in v0.9.4

func (i *Inertia) WithEncryptHistory(c fiber.Ctx)

WithEncryptHistory sets encryptHistory metadata for the response.

func (*Inertia) WithError

func (i *Inertia) WithError(c fiber.Ctx, field string, message string)

WithError adds a single validation error.

func (*Inertia) WithErrors

func (i *Inertia) WithErrors(c fiber.Ctx, errors map[string]string)

WithErrors adds validation errors to the response. Only adds to context; session is written via setFlashSessionData.

func (*Inertia) WithFlash

func (i *Inertia) WithFlash(c fiber.Ctx, key FlashLevel, message string)

WithFlash adds flash message to the response. Only adds to context; session is written via setFlashSessionData.

func (*Inertia) WithFlashError

func (i *Inertia) WithFlashError(c fiber.Ctx, message string)

WithFlashError adds error flash message.

func (*Inertia) WithFlashInfo

func (i *Inertia) WithFlashInfo(c fiber.Ctx, message string)

WithFlashInfo adds info flash message.

func (*Inertia) WithFlashMessages

func (i *Inertia) WithFlashMessages(c fiber.Ctx, flashMessages ...FlashError)

WithFlashMessages adds flashes messages.

func (*Inertia) WithFlashOld

func (i *Inertia) WithFlashOld(c fiber.Ctx, data map[string]any)

WithFlashOld adds flash message to the response. Only adds to context; session is written via setFlashSessionData.

func (*Inertia) WithFlashSuccess

func (i *Inertia) WithFlashSuccess(c fiber.Ctx, message string)

WithFlashSuccess adds success flash message.

func (*Inertia) WithFlashWarning

func (i *Inertia) WithFlashWarning(c fiber.Ctx, message string)

WithFlashWarning adds warning flash message.

func (*Inertia) WithLazyProp

func (i *Inertia) WithLazyProp(c fiber.Ctx, key string, fn func(context.Context) (any, error))

WithLazyProp adds a lazy-evaluated prop that's only computed when requested.

func (*Inertia) WithMatchPropsOn added in v0.9.2

func (i *Inertia) WithMatchPropsOn(c fiber.Ctx, props ...string)

WithMatchPropsOn sets matchPropsOn metadata for the response.

func (*Inertia) WithProp

func (i *Inertia) WithProp(c fiber.Ctx, key string, value any)

func (*Inertia) WithValidationErrors

func (i *Inertia) WithValidationErrors(c fiber.Ctx, errors ValidationErrors)

WithValidationErrors adds validation errors (equivalent to Django's form validation).

func (*Inertia) WithViewData

func (i *Inertia) WithViewData(c fiber.Ctx, key string, value any)

type LazyProp

type LazyProp struct {
	Key string
	Fn  func(ctx context.Context) (any, error)
}

LazyProp represents a prop that is evaluated lazily.

type Logger

type Logger interface {
	DebugContext(ctx context.Context, msg string, args ...any)
	InfoContext(ctx context.Context, msg string, args ...any)
	WarnContext(ctx context.Context, msg string, args ...any)
	ErrorContext(ctx context.Context, msg string, args ...any)
}

type LoggerAdapter

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

func NewLoggerAdapter

func NewLoggerAdapter(logger Logger) *LoggerAdapter

func (*LoggerAdapter) DebugContext

func (l *LoggerAdapter) DebugContext(ctx context.Context, msg string, args ...any)

func (*LoggerAdapter) ErrorContext

func (l *LoggerAdapter) ErrorContext(ctx context.Context, msg string, args ...any)

func (*LoggerAdapter) InfoContext

func (l *LoggerAdapter) InfoContext(ctx context.Context, msg string, args ...any)

func (*LoggerAdapter) WarnContext

func (l *LoggerAdapter) WarnContext(ctx context.Context, msg string, args ...any)

type MergeProp added in v0.9.2

type MergeProp struct {
	Value   any
	Prepend bool
	Deep    bool
}

MergeProp marks a prop as mergeable during partial reloads.

func DeepMerge added in v0.9.2

func DeepMerge(value any) MergeProp

DeepMerge wraps a value as a deep merge prop.

func Merge added in v0.9.2

func Merge(value any) MergeProp

Merge wraps a value as a merge prop.

func Prepend added in v0.9.2

func Prepend(value any) MergeProp

Prepend wraps a value as a prepend merge prop.

type OnceOption added in v0.9.2

type OnceOption func(*OnceProp)

OnceOption configures a OnceProp.

func WithOnceExpiresAt added in v0.9.2

func WithOnceExpiresAt(t time.Time) OnceOption

WithOnceExpiresAt sets an expiration time for a once prop.

func WithOnceKey added in v0.9.2

func WithOnceKey(key string) OnceOption

WithOnceKey sets a custom key for a once prop.

type OnceProp added in v0.9.2

type OnceProp struct {
	Key       string
	ExpiresAt *int64
	Value     any
}

OnceProp marks a prop as once and optionally sets expiration.

func Once added in v0.9.2

func Once(value any, opts ...OnceOption) OnceProp

Once wraps a value as a once prop.

type OncePropConfig added in v0.9.2

type OncePropConfig struct {
	Prop      string `json:"prop"`
	ExpiresAt *int64 `json:"expiresAt"`
}

OncePropConfig defines a once prop configuration. ExpiresAt is a unix timestamp in milliseconds. Nil encodes as null.

type Option

type Option func(*Inertia)

func WithAssetVersion

func WithAssetVersion(assetVersion string) Option

func WithCSRFPropName

func WithCSRFPropName(prop string) Option

WithCSRFPropName overrides the prop key used when injecting CSRF token.

func WithCSRFTokenCheckProvider

func WithCSRFTokenCheckProvider(provider CSRFTokenCheckProvider) Option

WithCSRFTokenCheckProvider registers a resolver that check CSRF token into every rendered page.

func WithCSRFTokenProvider

func WithCSRFTokenProvider(provider CSRFTokenProvider) Option

WithCSRFTokenProvider registers a resolver that injects CSRF token into every rendered page.

func WithCanExposeDetails

func WithCanExposeDetails(fn func(ctx context.Context, headers map[string][]string) bool) Option

WithCanExposeDetails sets a callback to decide if current request may see error details in production. Useful to allow main admins to see full error messages.

func WithCustomErrorDetailsHandler

func WithCustomErrorDetailsHandler(fn func(errReturn *Error, isCanDetails bool) string) Option

WithCustomErrorDetailsHandler sets a callback to handler error details.

func WithCustomErrorGettingHandler

func WithCustomErrorGettingHandler(fn func(err error) *Error) Option

WithCustomErrorGettingHandler sets function callback for custom getting errors.

func WithDevMode added in v0.9.1

func WithDevMode() Option

WithDevMode enables development mode. In this mode, the Vite hot file is checked on every request, allowing for dynamic starts/restarts of the Vite server.

func WithFS

func WithFS(fs fs.FS) Option

func WithLogger

func WithLogger(logger Logger) Option

func WithPrecognitionVary added in v0.9.4

func WithPrecognitionVary(enabled bool) Option

WithPrecognitionVary controls whether "Vary: Precognition" is added to Inertia responses. Defaults to true to match the protocol recommendation.

func WithPublicFS

func WithPublicFS(fs fs.ReadFileFS) Option

func WithRootErrorTemplate

func WithRootErrorTemplate(rootErrorTemplate string) Option

func WithRootHotTemplate

func WithRootHotTemplate(rootHotTemplate string) Option

func WithRootTemplate

func WithRootTemplate(rootTemplate string) Option

func WithSSRConfig

func WithSSRConfig(cfg SSRConfig) Option

WithSSRConfig enables SSR with the provided config.

func WithSessionStore

func WithSessionStore(sessionStore SessionStore) Option

func WithSetSharedFuncMap

func WithSetSharedFuncMap(data template.FuncMap) Option

func WithSharedProps

func WithSharedProps(data map[string]any) Option

func WithSharedViewData

func WithSharedViewData(data map[string]any) Option

type OptionalProp added in v0.9.2

type OptionalProp struct {
	Value any
}

OptionalProp marks a prop as optional (only included when explicitly requested).

func Optional added in v0.9.2

func Optional(value any) OptionalProp

Optional wraps a value as an optional prop.

type PageDTO

type PageDTO struct {
	Component      string                      `json:"component"`
	Props          map[string]any              `json:"props"`
	URL            string                      `json:"url"`
	Version        string                      `json:"version"`
	EncryptHistory bool                        `json:"encryptHistory,omitempty"`
	ClearHistory   bool                        `json:"clearHistory,omitempty"`
	DeferredProps  map[string][]string         `json:"deferredProps,omitempty"`
	MergeProps     []string                    `json:"mergeProps,omitempty"`
	PrependProps   []string                    `json:"prependProps,omitempty"`
	DeepMergeProps []string                    `json:"deepMergeProps,omitempty"`
	MatchPropsOn   []string                    `json:"matchPropsOn,omitempty"`
	ScrollProps    map[string]ScrollPropConfig `json:"scrollProps,omitempty"`
	OnceProps      map[string]OncePropConfig   `json:"onceProps,omitempty"`
}

PageDTO type.

type SSRClient added in v0.9.2

type SSRClient interface {
	Reset()
	Post(ctx context.Context, url string, body []byte, headers map[string]string) (int, []byte, error)
}

type SSRConfig

type SSRConfig struct {
	URL             string
	Timeout         time.Duration
	Headers         map[string]string
	CacheTTL        time.Duration
	CacheMaxEntries int
	SSRClient       SSRClient
	MaxRetries      int
	RetryDelay      time.Duration
	RetryStatuses   []int
	DisableRetries  bool
}

type ScrollProp added in v0.9.2

type ScrollProp struct {
	Value  any
	Config ScrollPropConfig
}

ScrollProp marks a prop as an infinite-scroll prop and adds scroll metadata.

func Scroll added in v0.9.2

func Scroll(value any, cfg ScrollPropConfig) ScrollProp

Scroll wraps a value as a scroll prop with metadata.

type ScrollPropConfig added in v0.9.2

type ScrollPropConfig struct {
	PageName     string `json:"pageName,omitempty"`
	PreviousPage any    `json:"previousPage,omitempty"`
	NextPage     any    `json:"nextPage,omitempty"`
	CurrentPage  any    `json:"currentPage,omitempty"`
}

ScrollPropConfig defines pagination metadata for infinite scroll props.

type SessionAdapter

type SessionAdapter[T FiberSessionStore] interface {
	Get(c fiber.Ctx) (T, error)
}

type SessionStore

type SessionStore interface {
	Get(c fiber.Ctx, key string) (any, error)
	Set(c fiber.Ctx, key string, value any) error
	Delete(c fiber.Ctx, key string) error
	Flash(c fiber.Ctx, key string, value any) error
	GetFlash(c fiber.Ctx, key string) (any, error)
}

type SsrDTO

type SsrDTO struct {
	Head []string `json:"head"`
	Body string   `json:"body"`
}

SsrDTO type.

type ValidationError

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

func NewValidationError

func NewValidationError(code int, userMessage string, errs ValidationErrors) *ValidationError

NewValidationError creates a ValidationError.

func (*ValidationError) Error

func (e *ValidationError) Error() string

func (*ValidationError) Errors

func (e *ValidationError) Errors() ValidationErrors

type ValidationErrors

type ValidationErrors map[string][]string

Directories

Path Synopsis
examples
basic-app command
basic-app-react command
basic-app-ssr command
Package goinertiamocks is a generated GoMock package.
Package goinertiamocks is a generated GoMock package.

Jump to

Keyboard shortcuts

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