script

package
v0.0.0-...-41d8e0c Latest Latest
Warning

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

Go to latest
Published: Dec 24, 2025 License: GPL-3.0 Imports: 10 Imported by: 0

README

Script App

Executes scripts using the go-polyscript library.

Data Sources

Scripts receive data from multiple sources:

  1. HTTP Request - Full request object available to scripts
  2. Static Data - Configured values from TOML configuration
  3. Route Data - Per-endpoint static data overrides
  4. JSON Body - Parsed JSON fields accessible directly

Configuration

Configure scripts in your TOML file under [[apps]] with [apps.script] section. See the main documentation for configuration examples.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	// ID is the unique identifier for this app instance
	ID string

	// CompiledEvaluator is the pre-compiled script evaluator from domain validation.
	// This evaluator is ready to execute and contains all compiled resources.
	CompiledEvaluator platform.Evaluator

	// StaticData contains pre-processed static data from the domain configuration.
	// This data is embedded during domain validation for runtime use.
	StaticData map[string]any

	// Logger is the structured logger configured for this app instance
	Logger *slog.Logger

	// ExecTimeout is the maximum execution time for script evaluation
	ExecTimeout time.Duration
}

Config contains everything needed to instantiate a script app. This is a Data Transfer Object (DTO) with no dependencies on domain packages. All validation and resource compilation happens at the domain layer before creating this config.

type ScriptApp

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

ScriptApp implements the server-side script application using go-polyscript

func New

func New(cfg *Config) (*ScriptApp, error)

New creates a new script app instance from a Config DTO

func (*ScriptApp) HandleHTTP

func (s *ScriptApp) HandleHTTP(
	ctx context.Context,
	w http.ResponseWriter,
	r *http.Request,
) error

HandleHTTP handles HTTP requests by executing the script using go-polyscript

func (*ScriptApp) String

func (s *ScriptApp) String() string

String returns the unique identifier of the application

Jump to

Keyboard shortcuts

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