Versions in this module Expand all Collapse all v0 v0.0.7 Jan 17, 2026 v0.0.6 Jan 15, 2026 v0.0.5 Jan 15, 2026 v0.0.4 Jan 15, 2026 v0.0.3 Jan 5, 2026 v0.0.2 Jan 4, 2026 v0.0.1 Dec 23, 2025 Changes in this version + const ErrCodeBadRequest + const ErrCodeForbidden + const ErrCodeInternal + const ErrCodeInvalidParams + const ErrCodeInvalidRequest + const ErrCodeMethodNotFound + const ErrCodeParseError + const ErrCodeRateLimit + const ErrCodeTimeout + const ErrCodeUnauthorized + var ErrBadRequest = NewError(ErrCodeBadRequest, "Bad request") + var ErrForbidden = NewError(ErrCodeForbidden, "Forbidden") + var ErrInternal = NewError(ErrCodeInternal, "Internal error") + var ErrInvalidParams = NewError(ErrCodeInvalidParams, "Invalid params") + var ErrInvalidRequest = NewError(ErrCodeInvalidRequest, "Invalid request") + var ErrMethodNotFound = NewError(ErrCodeMethodNotFound, "Method not found") + var ErrParseError = NewError(ErrCodeParseError, "Parse error") + var ErrRateLimit = NewError(ErrCodeRateLimit, "Rate limit exceeded") + var ErrTimeout = NewError(ErrCodeTimeout, "Request timeout") + var ErrUnauthorized = NewError(ErrCodeUnauthorized, "Unauthorized") + func BridgeMiddleware(bridge *Bridge) func(http.Handler) http.Handler + func BridgeScripts(config ScriptConfig) g.Node + func BridgeScriptsExternal(config ScriptConfig) g.Node + func GenerateCSRFToken() (string, error) + func GetAlpineJS() string + func GetBridgeJS() string + func GetClientIP(r *http.Request) string + func ScriptTemplate(tmpl string, data any) (g.Node, error) + func SetCSRFCookie(w http.ResponseWriter, token string, cookieName string) + func ValidateAlphanumeric(value string) error + func ValidateEmail(email string) error + func ValidateFloatRange(value, minValue, maxValue float64) error + func ValidateInput(input string) error + func ValidateLength(value string, minLength, maxLength int) error + func ValidateOneOf(value string, allowed []string) error + func ValidatePattern(value, pattern string) error + func ValidateRange(value, minValue, maxValue int) error + func ValidateRequired(value string) error + func ValidateSlug(slug string) error + func ValidateURL(url string) error + func WithBridgeContext(ctx context.Context, bridgeCtx Context) context.Context + func WriteSSE(w http.ResponseWriter, event StreamEvent) error + type BatchRequest []Request + type BatchResponse []Response + type Bridge struct + func New(opts ...ConfigOption) *Bridge + func WithBridgeCache(b *Bridge, cache Cache) *Bridge + func (b *Bridge) Call(ctx Context, funcName string, params json.RawMessage) (any, error) + func (b *Bridge) CallBatch(ctx Context, requests []Request) []Response + func (b *Bridge) FunctionCount() int + func (b *Bridge) GetConfig() *Config + func (b *Bridge) GetFunction(name string) (*Function, error) + func (b *Bridge) GetFunctionInfo(name string) (*FunctionInfo, error) + func (b *Bridge) GetHooks() *HookManager + func (b *Bridge) Handler() http.Handler + func (b *Bridge) HasFunction(name string) bool + func (b *Bridge) IntrospectionHandler() http.Handler + func (b *Bridge) ListFunctionInfo() []FunctionInfo + func (b *Bridge) ListFunctions() []string + func (b *Bridge) Register(name string, handler any, opts ...FunctionOption) error + func (b *Bridge) StreamHandler() http.Handler + func (b *Bridge) Unregister(name string) error + type Cache interface + Clear func() + Delete func(key string) + Get func(key string) (any, bool) + Set func(key string, value any, ttl time.Duration) + type Config struct + AllowedOrigins []string + CSRFCookieName string + CSRFTokenHeader string + DefaultRateLimit int + EnableCORS bool + EnableCSRF bool + EnableCache bool + MaxBatchSize int + Timeout time.Duration + func DefaultConfig() *Config + type ConfigOption func(*Config) + func WithAllowedOrigins(origins ...string) ConfigOption + func WithCORS(enabled bool) ConfigOption + func WithCSRF(enabled bool) ConfigOption + func WithCache(enabled bool) ConfigOption + func WithDefaultRateLimit(rpm int) ConfigOption + func WithMaxBatchSize(size int) ConfigOption + func WithTimeout(d time.Duration) ConfigOption + type Context interface + Context func() context.Context + Request func() *http.Request + Session func() Session + SetValue func(key, val any) + User func() User + Value func(key any) any + func GetBridgeContext(ctx context.Context) (Context, bool) + func NewContext(r *http.Request) Context + func WithSession(ctx Context, session Session) Context + func WithUser(ctx Context, user User) Context + type Error struct + Code int + Data any + Message string + func NewError(code int, message string, data ...any) *Error + func (e *Error) Error() string + type Event struct + Data any + Type string + type ExecuteResult struct + Error *Error + Result any + type FieldInfo struct + JSONName string + Name string + Required bool + Type string + type Function struct + CacheTTL time.Duration + Cacheable bool + Description string + Handler reflect.Value + InputType reflect.Type + Name string + OutputType reflect.Type + RateLimit int + RequireAuth bool + RequireRoles []string + Timeout time.Duration + func (f *Function) GetTypeInfo() TypeInfo + type FunctionInfo struct + Description string + Name string + RateLimit int + RequireAuth bool + RequireRoles []string + TypeInfo TypeInfo + type FunctionOption func(*Function) + func RequireAuth() FunctionOption + func RequireRoles(roles ...string) FunctionOption + func WithDescription(desc string) FunctionOption + func WithFunctionCache(ttl time.Duration) FunctionOption + func WithFunctionTimeout(d time.Duration) FunctionOption + func WithRateLimit(rpm int) FunctionOption + type HTTPHandler struct + func NewHTTPHandler(bridge *Bridge) *HTTPHandler + func (h *HTTPHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) + type Hook func(ctx Context, data HookData) + type HookData struct + Duration int64 + Error error + FunctionName string + Params any + Result any + type HookManager struct + func NewHookManager() *HookManager + func (hm *HookManager) Clear(hookType HookType) + func (hm *HookManager) ClearAll() + func (hm *HookManager) Count(hookType HookType) int + func (hm *HookManager) Register(hookType HookType, hook Hook) + func (hm *HookManager) Trigger(hookType HookType, ctx Context, data HookData) + type HookType string + const AfterCall + const BeforeCall + const OnError + const OnSuccess + type Integration struct + func NewIntegration(bridge *Bridge) *Integration + func (i *Integration) RegisterHTTPRoutes(mux *http.ServeMux) + type IntrospectionHandler struct + func NewIntrospectionHandler(bridge *Bridge) *IntrospectionHandler + func (h *IntrospectionHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) + type MemoryCache struct + func NewMemoryCache() *MemoryCache + func (c *MemoryCache) Clear() + func (c *MemoryCache) Count() int + func (c *MemoryCache) Delete(key string) + func (c *MemoryCache) Get(key string) (any, bool) + func (c *MemoryCache) Set(key string, value any, ttl time.Duration) + type Middleware func(http.Handler) http.Handler + func CORSMiddleware(allowedOrigins []string) Middleware + func Chain(middlewares ...Middleware) Middleware + func LoggerMiddleware() Middleware + func RecoveryMiddleware() Middleware + func RequestIDMiddleware() Middleware + type RateLimiter struct + func NewRateLimiter(rate, burst int) *RateLimiter + func (rl *RateLimiter) Allow(key string) bool + func (rl *RateLimiter) Count() int + func (rl *RateLimiter) Remaining(key string) int + func (rl *RateLimiter) Reset(key string) + type Request struct + ID any + JSONRPC string + Method string + Params json.RawMessage + type Response struct + Error *Error + ID any + JSONRPC string + Result any + type SSEHandler struct + func NewSSEHandler(bridge *Bridge) *SSEHandler + func (h *SSEHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) + type ScriptConfig struct + CSRFToken string + Endpoint string + IncludeAlpine bool + type Security struct + func NewSecurity(config *Config) *Security + func (s *Security) CheckAuth(ctx Context, fn *Function) error + func (s *Security) CheckCSRF(r *http.Request) error + func (s *Security) CheckRateLimit(key string, fn *Function) error + type Session interface + Clear func() + Delete func(key string) + Get func(key string) (any, bool) + ID func() string + Set func(key string, value any) + type SimpleSession struct + SessionID string + func NewSimpleSession(id string) *SimpleSession + func (s *SimpleSession) Clear() + func (s *SimpleSession) Delete(key string) + func (s *SimpleSession) Get(key string) (any, bool) + func (s *SimpleSession) ID() string + func (s *SimpleSession) Set(key string, value any) + type SimpleUser struct + UserData map[string]any + UserEmail string + UserID string + UserName string + UserRoles []string + func (u *SimpleUser) Data() map[string]any + func (u *SimpleUser) Email() string + func (u *SimpleUser) HasRole(role string) bool + func (u *SimpleUser) ID() string + func (u *SimpleUser) Name() string + func (u *SimpleUser) Roles() []string + type StreamChunk struct + Data any + Done bool + Error *Error + type StreamEvent struct + Data any + Event string + ID string + type TypeInfo struct + Fields []FieldInfo + InputType string + Name string + OutputType string + type User interface + Data func() map[string]any + Email func() string + HasRole func(role string) bool + ID func() string + Name func() string + Roles func() []string + type WSHandler struct + func NewWSHandler(bridge *Bridge) *WSHandler + func (h *WSHandler) Broadcast(event Event) + func (h *WSHandler) SendToUser(userID string, event Event) + func (h *WSHandler) ServeHTTP(w http.ResponseWriter, r *http.Request)