Documentation
¶
Overview ¶
Package script runs a request's pre-/post-request Lua scripts, giving them a small object model (client.global, response) plus file-read and command-exec capabilities via github.com/vadv/gopher-lua-libs.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func RunPostScript ¶
func RunPostScript(source string, result client.Result, global *GlobalState) error
RunPostScript executes a request's "> {% ... %}" script after its response is received. It additionally has access to response.
func RunPreScript ¶
func RunPreScript(source string, global *GlobalState) error
RunPreScript executes a request's "< {% ... %}" script before it's sent. It can read/write persisted globals via client.global, and use the preloaded cmd/ioutil/filepath/json modules for file and command work.
Types ¶
type GlobalState ¶
type GlobalState struct {
// contains filtered or unexported fields
}
GlobalState is one directory+environment's persisted "client.global" variables (see internal/state). Set writes through to disk immediately, so even a single ad-hoc request durably updates it for later runs.
func NewGlobalState ¶
func NewGlobalState(dir, envName string, vars map[string]string) *GlobalState
NewGlobalState wraps an already-loaded variable set (internal/state.Load) for use by scripts run against the same directory and environment.
func (*GlobalState) Vars ¶
func (g *GlobalState) Vars() map[string]string
Vars returns the current variables, e.g. to merge into interpolation for requests after any scripts that ran before them.