Help us shape the future of Go! Take the 2026 Go Developer Survey

engine

package
v0.2.3 Latest Latest
Warning

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

Go to latest
Published: Sep 18, 2026 License: MIT Imports: 24 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ValidateIngress added in v0.2.1

func ValidateIngress(ctx *Context, rules *manifest.Request, schemas map[string]manifest.Schema) *problem.Problem

ValidateIngress validates path, query, header, and body parameters against configured request rules. Valid scalar path and query parameters are coerced to native Go types (int64, float64, bool) in place.

Types

type Context added in v0.2.0

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

Context encapsulates the runtime execution state and dependency provider for a single HTTP request. It implements manifest.StepExecutionContext.

func NewContext added in v0.2.0

func NewContext(
	r *http.Request,
	w http.ResponseWriter,
	routePattern string,
	maxBodySize int64,
	deps Dependencies,
) (*Context, error)

NewContext constructs an execution context, enforcing body boundaries, normalizing headers, and capturing a frozen reference timestamp that remains immutable throughout the request lifecycle.

func (*Context) Body added in v0.2.1

func (c *Context) Body() any

Body returns the parsed JSON structure or raw text body.

func (*Context) BodyMalformed added in v0.2.1

func (c *Context) BodyMalformed() bool

BodyMalformed reports whether the incoming JSON payload contained syntax errors.

func (*Context) GoHandler added in v0.2.1

func (c *Context) GoHandler(name string) (manifest.StepHandler, error)

GoHandler implements manifest.StepExecutionContext and returns a registered Go callback.

func (*Context) HTTPClient added in v0.2.1

func (c *Context) HTTPClient() *http.Client

HTTPClient implements manifest.StepExecutionContext.

func (*Context) OpenAPISpec added in v0.2.1

func (c *Context) OpenAPISpec(format string) ([]byte, string, error)

OpenAPISpec implements manifest.StepExecutionContext and returns the precompiled specification and ETag.

func (*Context) ResponseController added in v0.2.1

func (c *Context) ResponseController() *http.ResponseController

ResponseController implements manifest.StepExecutionContext.

func (*Context) ResponseWriter added in v0.2.1

func (c *Context) ResponseWriter() http.ResponseWriter

ResponseWriter implements manifest.StepExecutionContext.

func (*Context) SQL added in v0.2.1

func (c *Context) SQL(name string) (*sql.DB, error)

SQL implements manifest.StepExecutionContext and returns a managed database pool by name.

func (*Context) Schemas added in v0.2.1

func (c *Context) Schemas() map[string]manifest.Schema

Schemas implements manifest.StepExecutionContext.

func (*Context) Scope added in v0.2.1

func (c *Context) Scope() manifest.Scope

Scope implements manifest.StepExecutionContext and constructs an immutable expression evaluation scope.

func (*Context) SetBody added in v0.2.1

func (c *Context) SetBody(body any)

SetBody replaces the body payload, typically after defaults injection during ingress validation.

func (*Context) SetPathParam added in v0.2.1

func (c *Context) SetPathParam(name string, val any)

SetPathParam assigns a coerced scalar value to a path parameter coordinate.

func (*Context) SetQueryParam added in v0.2.1

func (c *Context) SetQueryParam(name string, val any)

SetQueryParam assigns a coerced scalar or slice value to a query parameter coordinate.

func (*Context) SetStepResult added in v0.2.0

func (c *Context) SetStepResult(name string, result any)

SetStepResult records a completed step's output under its published identifier.

func (*Context) Telemetry added in v0.2.1

func (c *Context) Telemetry() *telemetry.Telemetry

Telemetry returns the active telemetry instance configured for the request context.

func (*Context) Valkey added in v0.2.1

func (c *Context) Valkey(name string) (valkey.Client, error)

Valkey implements manifest.StepExecutionContext and returns an active Valkey client by name.

type Dependencies added in v0.2.1

type Dependencies struct {
	SQL        map[string]*sql.DB
	Valkey     map[string]valkey.Client
	Handlers   map[string]manifest.StepHandler
	Schemas    map[string]manifest.Schema
	Spec       *openapi.Spec
	HTTPClient *http.Client
	Telemetry  *telemetry.Telemetry
}

Dependencies provides runtime connection pools, handlers, schemas, specifications, and telemetry instrumentation to Context.

type Engine

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

Engine coordinates HTTP routing, connection pool lifecycles, and request execution. It implements the standard http.Handler interface.

func New

func New(m *manifest.Manifest, opts ...Option) (*Engine, error)

New initializes an Engine from a validated manifest.Manifest, opening connection pools, configuring telemetry, precompiling OpenAPI specifications, and binding routes.

func (*Engine) Close

func (e *Engine) Close() error

Close cleanly terminates all managed database pools, Valkey clients, and idle outbound HTTP connections.

func (*Engine) SQL added in v0.2.0

func (e *Engine) SQL(name string) (*sql.DB, bool)

SQL returns an active database pool by connection name.

func (*Engine) ServeHTTP added in v0.2.0

func (e *Engine) ServeHTTP(w http.ResponseWriter, r *http.Request)

ServeHTTP satisfies the standard http.Handler interface by dispatching through telemetry middleware.

func (*Engine) Telemetry added in v0.2.1

func (e *Engine) Telemetry() *telemetry.Telemetry

Telemetry returns the active telemetry.Telemetry instance managing logging and tracing.

func (*Engine) Valkey added in v0.2.0

func (e *Engine) Valkey(name string) (valkey.Client, bool)

Valkey returns an active Valkey client by connection name.

type Option added in v0.2.0

type Option func(*Engine)

Option configures an Engine during initialization.

func WithGoHandler added in v0.2.1

func WithGoHandler(name string, h manifest.StepHandler) Option

WithGoHandler registers a custom native Go callback by its identifier.

func WithHTTPClient added in v0.2.1

func WithHTTPClient(client *http.Client) Option

WithHTTPClient overrides the default HTTP client used for outbound requests.

func WithTelemetry added in v0.2.1

func WithTelemetry(t *telemetry.Telemetry) Option

WithTelemetry overrides the default telemetry instance configured by the manifest.

Jump to

Keyboard shortcuts

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