handlers

package
v0.3.2 Latest Latest
Warning

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

Go to latest
Published: Jul 1, 2025 License: MIT Imports: 26 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CachedModule added in v0.3.0

type CachedModule struct {
	Exports      *js.Object
	LastModified time.Time
}

CachedModule represents a cached JavaScript module

type JSEnginePool added in v0.3.0

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

JSEnginePool manages a pool of JavaScript engines

func GetJSEnginePool added in v0.3.0

func GetJSEnginePool(fs filesystem.FileSystem, version string) *JSEnginePool

GetJSEnginePool returns a JavaScript engine pool for the given filesystem

func (*JSEnginePool) GetEngine added in v0.3.0

func (pool *JSEnginePool) GetEngine() (*SharedJSEngine, error)

GetEngine gets an available engine from the pool

func (*JSEnginePool) GetEngineForSession added in v0.3.0

func (pool *JSEnginePool) GetEngineForSession(sessionID string) (*SharedJSEngine, error)

GetEngineForSession gets an engine specifically for a session/client

func (*JSEnginePool) ReleaseSessionEngine added in v0.3.0

func (pool *JSEnginePool) ReleaseSessionEngine(sessionID string)

ReleaseSessionEngine releases an engine from a session (for cleanup)

func (*JSEnginePool) ReturnEngine added in v0.3.0

func (pool *JSEnginePool) ReturnEngine(engine *SharedJSEngine)

ReturnEngine returns an engine to the pool

func (*JSEnginePool) Stop added in v0.3.0

func (pool *JSEnginePool) Stop()

Stop stops all engines in the pool

type JavaScriptHandler

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

func NewJavaScriptHandler

func NewJavaScriptHandler(fs filesystem.FileSystem) *JavaScriptHandler

func NewJavaScriptHandlerWithVersion

func NewJavaScriptHandlerWithVersion(fs filesystem.FileSystem, version string) *JavaScriptHandler

func (*JavaScriptHandler) Handle

func (jh *JavaScriptHandler) Handle(route Route) http.HandlerFunc

type Route

type Route struct {
	Path      string
	FilePath  string
	FileType  string
	IsDynamic bool
	ParamName string
}

Route represents a single route in the application

type SharedJSEngine added in v0.3.0

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

SharedJSEngine manages a shared JavaScript environment with module caching

func (*SharedJSEngine) ExecuteHTTPMethod added in v0.3.0

func (engine *SharedJSEngine) ExecuteHTTPMethod(r *http.Request, w http.ResponseWriter, route Route) error

ExecuteHTTPMethod executes an HTTP method handler from a JavaScript module

func (*SharedJSEngine) Start added in v0.3.0

func (engine *SharedJSEngine) Start() error

Start initializes the shared JavaScript engine

func (*SharedJSEngine) Stop added in v0.3.0

func (engine *SharedJSEngine) Stop()

Stop shuts down the shared JavaScript engine

type TemplateHandler added in v0.3.0

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

func NewTemplateHandler added in v0.3.0

func NewTemplateHandler(fs filesystem.FileSystem) *TemplateHandler

func (*TemplateHandler) Handle added in v0.3.0

func (th *TemplateHandler) Handle(route Route) http.HandlerFunc

func (*TemplateHandler) RenderTemplate added in v0.3.0

func (th *TemplateHandler) RenderTemplate(templatePath, templateContent string, data interface{}, w http.ResponseWriter) error

RenderTemplate renders a template file with the given data

type VMManager added in v0.2.0

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

VMManager manages JavaScript VM creation and module initialization

func NewVMManager added in v0.2.0

func NewVMManager(fs filesystem.FileSystem, version string) *VMManager

NewVMManager creates a new VM manager

func (*VMManager) SetupRegistry added in v0.2.0

func (vm *VMManager) SetupRegistry(loop *eventloop.EventLoop, jsVM *js.Runtime, basePath string) (*require.Registry, error)

SetupRegistry creates and configures a require registry with all modules

Jump to

Keyboard shortcuts

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