Documentation
¶
Index ¶
- Constants
- Variables
- func GetExtension[T Extension](b *Bat) T
- type Bat
- type BatContext
- type BatOption
- type Controller
- type DatabaseExtension
- type Extension
- type FlashExtension
- func (f *FlashExtension) FlashClearHistory(ctx context.Context) error
- func (f *FlashExtension) FlashErrors(ctx context.Context, errors gonertia.ValidationErrors) error
- func (f *FlashExtension) GetErrors(ctx context.Context) (gonertia.ValidationErrors, error)
- func (f *FlashExtension) Register(app *Bat) error
- func (f *FlashExtension) Requirements() []reflect.Type
- func (f *FlashExtension) ShouldClearHistory(ctx context.Context) (bool, error)
- type FlashExtensionOption
- type InertiaExtension
- type InertiaExtensionOption
- func WithDevServerURL(devServerURL string) InertiaExtensionOption
- func WithFrontendPath(frontendPath string) InertiaExtensionOption
- func WithIgnoreList(ignoreList []string) InertiaExtensionOption
- func WithJSRuntime(jsRuntime string) InertiaExtensionOption
- func WithRootTemplate(rootTemplate []byte) InertiaExtensionOption
- type Logger
- type LoggerOutputType
- type SessionExtension
- func (s *SessionExtension) AttachSessionIDToRequestContext() echo.MiddlewareFunc
- func (s *SessionExtension) EnsureSession() echo.MiddlewareFunc
- func (s *SessionExtension) GetSessionIDFromRequest(ctx context.Context) string
- func (s *SessionExtension) Register(app *Bat) error
- func (s *SessionExtension) Requirements() []reflect.Type
- type SessionExtensionOption
- type ValkeyExtension
Constants ¶
const DefaultFlashClearHistoryKeyPrefix = "flash_clear_history:"
const DefaultFlashErrKeyPrefix = "flash_err:"
const DefaultSessionKey = "session_id"
const DefaultSessionName = "session"
Variables ¶
var ( ExtensionNotPointerError = errors.New("given extension must be a pointer") CyclicDependencyError = errors.New("cyclic extension dependency detected") )
var DefaultIgnoreList = []string{"api", "swagger"}
DefaultIgnoreList is the default list of paths that will be ignored by the dev proxy
var DefaultInertiaRootTemplate []byte
Functions ¶
func GetExtension ¶
Types ¶
type Bat ¶
type Bat struct {
Logger *Logger
*echo.Echo
// SkipPaths is a list of paths that should not be logged
SkipPaths []string
// contains filtered or unexported fields
}
func (*Bat) NewContext ¶
func (*Bat) RegisterControllers ¶
func (b *Bat) RegisterControllers(controllers ...Controller) error
type BatContext ¶
type Controller ¶
type DatabaseExtension ¶
type DatabaseExtension struct {
// contains filtered or unexported fields
}
func NewDatabaseExtension ¶
func NewDatabaseExtension(db *sqlx.DB) *DatabaseExtension
func (*DatabaseExtension) GetDB ¶
func (d *DatabaseExtension) GetDB() *sqlx.DB
func (*DatabaseExtension) Register ¶
func (d *DatabaseExtension) Register(app *Bat) error
func (*DatabaseExtension) Requirements ¶
func (d *DatabaseExtension) Requirements() []reflect.Type
type FlashExtension ¶
type FlashExtension struct {
// contains filtered or unexported fields
}
FlashExtension is an extension that provides error flash functionality
func NewFlashExtension ¶
func NewFlashExtension(opts ...FlashExtensionOption) (*FlashExtension, error)
NewFlashExtension creates a new flash extension, it expects that the context contains a sessionID
func (*FlashExtension) FlashClearHistory ¶
func (f *FlashExtension) FlashClearHistory(ctx context.Context) error
FlashClearHistory sets the flash clear history flag
func (*FlashExtension) FlashErrors ¶
func (f *FlashExtension) FlashErrors(ctx context.Context, errors gonertia.ValidationErrors) error
FlashErrors adds the errors to the flash provider
func (*FlashExtension) GetErrors ¶
func (f *FlashExtension) GetErrors(ctx context.Context) (gonertia.ValidationErrors, error)
GetErrors returns the errors from the flash provider
func (*FlashExtension) Register ¶
func (f *FlashExtension) Register(app *Bat) error
Register registers the flash extension
func (*FlashExtension) Requirements ¶
func (f *FlashExtension) Requirements() []reflect.Type
Requirements returns the requirements for the flash extension
func (*FlashExtension) ShouldClearHistory ¶
func (f *FlashExtension) ShouldClearHistory(ctx context.Context) (bool, error)
ShouldClearHistory returns whether the history should be cleared
type FlashExtensionOption ¶
type FlashExtensionOption func(*FlashExtension) error
FlashExtensionOption is a function that modifies the FlashExtension
func WithFlashClearHistoryKeyPrefix ¶
func WithFlashClearHistoryKeyPrefix(prefix string) FlashExtensionOption
WithFlashClearHistoryKeyPrefix sets the flash clear history key prefix
func WithFlashErrKeyPrefix ¶
func WithFlashErrKeyPrefix(prefix string) FlashExtensionOption
WithFlashErrKeyPrefix sets the flash error key prefix
type InertiaExtension ¶
type InertiaExtension struct {
// Inertia is the Inertia instance that will be used by the InertiaExtension
Inertia *gonertia.Inertia
// contains filtered or unexported fields
}
InertiaExtension is an extension that provides Inertia support to the application
func NewInertiaExtension ¶
func NewInertiaExtension(distDirFS fs.FS, manifest []byte, isDev bool, opts ...InertiaExtensionOption) (*InertiaExtension, error)
NewInertiaExtension creates a new InertiaExtension
func (*InertiaExtension) Register ¶
func (i *InertiaExtension) Register(app *Bat) error
Register registers the InertiaExtension
func (*InertiaExtension) Requirements ¶
func (i *InertiaExtension) Requirements() []reflect.Type
Requirements returns the requirements for the InertiaExtension
type InertiaExtensionOption ¶
type InertiaExtensionOption func(i *InertiaExtension) error
InertiaExtensionOption is a function that sets an option on the InertiaExtension
func WithDevServerURL ¶
func WithDevServerURL(devServerURL string) InertiaExtensionOption
WithDevServerURL sets the dev server URL on the InertiaExtension
func WithFrontendPath ¶
func WithFrontendPath(frontendPath string) InertiaExtensionOption
WithFrontendPath sets the frontend path on the InertiaExtension
func WithIgnoreList ¶
func WithIgnoreList(ignoreList []string) InertiaExtensionOption
WithIgnoreList sets the ignore list on the InertiaExtension
func WithJSRuntime ¶
func WithJSRuntime(jsRuntime string) InertiaExtensionOption
WithJSRuntime sets the JS runtime on the InertiaExtension
func WithRootTemplate ¶
func WithRootTemplate(rootTemplate []byte) InertiaExtensionOption
WithRootTemplate sets the root template on the InertiaExtension
type Logger ¶
func NewLogger ¶
func NewLogger(outputType LoggerOutputType, opts *slog.HandlerOptions, noColor bool) *Logger
type LoggerOutputType ¶
type LoggerOutputType string
const ( LoggerOutputTypeHuman LoggerOutputType = "human" LoggerOutputTypeJSON LoggerOutputType = "json" )
type SessionExtension ¶
type SessionExtension struct {
// contains filtered or unexported fields
}
SessionExtension is an extension that provides session management
func NewSessionExtension ¶
func NewSessionExtension(opts ...SessionExtensionOption) (*SessionExtension, error)
NewSessionExtension creates a new session extension
func (*SessionExtension) AttachSessionIDToRequestContext ¶
func (s *SessionExtension) AttachSessionIDToRequestContext() echo.MiddlewareFunc
AttachSessionIDToRequestContext attaches the session ID to the request context
func (*SessionExtension) EnsureSession ¶
func (s *SessionExtension) EnsureSession() echo.MiddlewareFunc
EnsureSession ensures that the session is created
func (*SessionExtension) GetSessionIDFromRequest ¶
func (s *SessionExtension) GetSessionIDFromRequest(ctx context.Context) string
GetSessionIDFromRequest returns the session ID from the request context
func (*SessionExtension) Register ¶
func (s *SessionExtension) Register(app *Bat) error
Register registers the session extension
func (*SessionExtension) Requirements ¶
func (s *SessionExtension) Requirements() []reflect.Type
Requirements returns the requirements for the session extension
type SessionExtensionOption ¶
type SessionExtensionOption func(*SessionExtension) error
SessionExtensionOption is a function that modifies the SessionExtension
func WithSessionKey ¶
func WithSessionKey(key string) SessionExtensionOption
WithSessionKey sets the session key
func WithSessionName ¶
func WithSessionName(name string) SessionExtensionOption
WithSessionName sets the session name
func WithSessionStore ¶ added in v0.4.0
func WithSessionStore(store sessions.Store) SessionExtensionOption
WithSessionStore sets the session store
type ValkeyExtension ¶
type ValkeyExtension struct {
// contains filtered or unexported fields
}
ValkeyExtension is an extension that provides valkey functionality
func NewValkeyExtension ¶
func NewValkeyExtension(client valkey.Client) *ValkeyExtension
NewValkeyExtension creates a new valkey extension
func (*ValkeyExtension) GetClient ¶
func (v *ValkeyExtension) GetClient() valkey.Client
GetClient returns the valkey client
func (*ValkeyExtension) Register ¶
func (v *ValkeyExtension) Register(app *Bat) error
Register registers the valkey extension
func (*ValkeyExtension) Requirements ¶
func (v *ValkeyExtension) Requirements() []reflect.Type
Requirements returns the requirements of the valkey extension