Welcome to the new Golem Cloud Docs! 👋
Expression Language
The console is only available for Golem Cloud.

Expression Language

To make route definitions as flexible as possible Golem provides a powerful expression language that allows you to capture information as variables and perform conditional logic.

Here is an overview of the syntax you can use for capturing variables in your HTTP endpoint definition and accessing them later:

TypePath DefinitionAccess Method
Path Parametersusers/{user-id}${request.path.user-id}
Query Parametersusers/{user-id}?{active}${request.query.active}
Request BodyN/A${request.body}
Request Body FieldN/A${request.body.<FIELD_NAME>}
Request HeadersN/A${request.headers.<HEADER_NAME>}

Code is always indicated by ${…}. Any text that is not wrapped this way is interpreted as a string.

You can also use conditional logic. For example, you might want to have a different worker handle the request depending on one of the parameters.

You can do this with ${if condition then x else y} syntax or ${if condition1 then x elseif condition2 then y else z} if you have more than three branches.

In addition to equality comparison operators (, <, >=, and >) are currently supported in conditions.

The user interface of the management console has extensive help to make it easy for you to write these expressions and make sure that they are correct and well typed as you do so.

Input Expressions

Input expressions are used for capturing information from the request and making it available to the worker function. They are available in the request object.

Input expressions can be used to define the worker-id, and the function parameters of the selected worker function.

Path Parameters

Define a parameter in your path by wrapping it in curly brackets { }

Path DefinitionUsage

Query Parameters

Define a query parameter after the ? in your Path Definition. They are available under path parameters.

Path DefinitionUsage

Request Body

Use values included in the request body. You can select nested values and construct compound values.

Entire Request Body${request.body}
Specific Field in Request Body${request.body.FIELD_NAME}
Specific index in Request Body Array${request.body[INDEX]}

Response Expressions

Worker functions always return a Tuple of values. You can refer to the entire return tuple, or access an individual value by index.

Entire Worker Function Response${worker.response}
Specific index in worker response${worker.response[INDEX]}
Nest Worker Response in JSON Object{ "response": "${worker.response}" }