script

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jun 12, 2026 License: MIT Imports: 15 Imported by: 0

Documentation

Overview

Package script runs JetBrains HTTP Client handler scripts ({% ... %}) on a goja JavaScript runtime. Each execution gets a fresh runtime with only the client/request/response objects registered — scripts have no filesystem, network, or process access. State persists between requests solely through vars.Globals.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Engine

type Engine struct {
	Globals *vars.Globals
	Out     io.Writer
	// Timeout is the wall-clock guard per script; zero means 5s.
	Timeout time.Duration
}

Engine executes pre-request and response handler scripts.

func (*Engine) RunPost

func (e *Engine) RunPost(code string, response *Response) ([]TestResult, error)

RunPost executes a response handler script and returns its client.test results.

func (*Engine) RunPre

func (e *Engine) RunPre(code string, req *PreRequest, setVar func(key, value string)) error

RunPre executes a pre-request script. Variables set via request.variables.set are delivered through setVar. req may be nil.

type PreRequest

type PreRequest struct {
	Method      string
	URL         string
	Body        string
	Headers     [][2]string
	Environment map[string]string
	Resolve     func(string) string
}

PreRequest is the raw (unresolved) view of the request a pre-request script is about to influence. Raw values keep their {{placeholders}}; Resolve backs the tryGetSubstituted views with the variables known at call time.

type Response

type Response struct {
	Status      int
	Headers     http.Header
	ContentType string
	Body        []byte
}

Response is the view of an HTTP response handed to response handler scripts.

type TestResult

type TestResult struct {
	Name    string
	Failed  bool
	Message string
}

TestResult is one client.test outcome.

Jump to

Keyboard shortcuts

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