request

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Aug 25, 2017 License: Apache-2.0 Imports: 15 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Response

type Response struct {
	Response    *http.Response
	RequestTime time.Duration
	Content     []byte
	Request     *http.Request
	Payload     []byte
}

Response - Helper object returned from making a request. It holds all the relevant request/response data.

func Do

func Do(epConfig *endpoint.EndpointConfig) (*Response, error)

Do - Performs the request for a given endpoint configuration. This will expand all variables, fake data, and execute any transforms and onComplete scripts specified.

func (*Response) IsResponseJSON

func (res *Response) IsResponseJSON() bool

IsResponseJSON - Returns true if the response is JSON. This is done by testing the Content-Type header.

type ScriptEngine

type ScriptEngine struct {
	VM             *otto.Otto
	Constants      map[string]string
	AssetPath      string
	Response       *Response
	EndpointConfig *endpoint.EndpointConfig
	Payload        []byte
	Request        *http.Request
	Debug          string
}

ScriptEngine - A scripting engine used to execute hook scripts during the request process. It is built to execute arbitrary Javascript.

func NewScriptEngine

func NewScriptEngine(endpointConfig *endpoint.EndpointConfig) *ScriptEngine

NewScriptEngine - Generates a new script engine.

func (*ScriptEngine) Execute

func (engine *ScriptEngine) Execute(script string) error

Execute - Executes a Javascript.

func (*ScriptEngine) ExecuteFile

func (eng *ScriptEngine) ExecuteFile(filepath string) error

ExecuteFile - Executes a script contianed in a file.

func (*ScriptEngine) SetPayload added in v0.2.0

func (engine *ScriptEngine) SetPayload(payload []byte)

SetPayload - Sets the request payload on the engine. Also exposes it to scripts within the request object.

func (*ScriptEngine) SetRequest added in v0.2.0

func (engine *ScriptEngine) SetRequest(request *http.Request)

SetRequest - Sets the request on the engine. This also builds the functions to expose the request to scripts.

func (*ScriptEngine) SetResponse

func (eng *ScriptEngine) SetResponse(res *Response)

SetResponse - Used to set the web respone on the engine. It also makes this available to the script.

func (*ScriptEngine) Validate

func (eng *ScriptEngine) Validate(script string) error

Validate - Validates that the Javascript is valid.

Jump to

Keyboard shortcuts

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