Contexts

Contexts provide a way for nodes to implicitly pass values along an execution path, eliminating the need for explicit connections. For example, when an Http Endpoint node receives a request, it automatically makes an EndpointContext available to nodes it connects to. This allows an Http Response node to access and respond to the request without requiring you to explicitly pass a request object.

You can check what contexts a trigger produces by hovering over its output.

Some input triggers require specific contexts to function. These triggers either consume or borrow contexts:

  • Consuming a context means it can only be used once. For example, Http.Response.execute consumes an EndpointContext, ensuring that a request can only be responded to once.

  • Borrowing a context means it can be used multiple times without consuming it. For example, Testing.AssertEqual.execute borrows a TestContext, allowing multiple assertions within the same test.

Some examples of functions in the standard library using contexts

  • Http Endpoint provides an EndpointContext, representing the incoming HTTP request, which is then consumed by the first call to Http Response.

  • Testing Test provides a TestContext, representing a running test instance. This context is then borrowed by assertion functions like Std AssertEqual.

  • Std For provides a context which keeps track of the current loop index.

Contexts in user defined functions

If your own functions use functions that require certain contexts, you need to explicitly add those contexts to your own functions triggers as well. If you for example want to perform an Http Response call in your function, you need consume an EndpointContext.

Click the + icon in the input trigger and search for EndpointContext.

Last updated

Was this helpful?