GoLand 2021.1 Help

HTTP Client reference

The client object holds the HTTP Client session metadata, such as the list of global variables. The HTTP Client session is started when GoLand starts, and ends when GoLand is closed. Values are not preserved between GoLand restarts.

The client provides access to the global nested object that serves as a variables storage.

Properties

PropertyDescription
global(Variables)

The global variables storage, which is used for setting, retrieving, or removing variables.

In your HTTP requests, you can access a variable saved in client.global as variable_name by using the {{variable_name}} syntax.

Methods

MethodParametersDescription
test

testName (string)

func (function)

Creates a test with the name testName and body func. All tests are executed after the response handler script.
assert

condition (boolean)

message (string)

Checks that the specified condition is true; throws an exception otherwise. The optional message parameter serves as an exception message.
logtextPrints text to the response handler or test stdout and then terminates the line.

Global variables storage

The global object serves as a variables storage and is used for setting, retrieving, or removing variables.

Methods

MethodParametersDescription
set

varName (string)

varValue (string)

Saves the variable with the varName name to the storage and sets its value to varValue.
getvarName (string)Returns the value of the varName variable.
isEmptyChecks whether the global object has no variables defined.
clearvarName (string)Removes the varName variable from the variables storage.
clearAllRemoves all variables from the variables storage.
Last modified: 08 March 2021