Skip to content

Overview

Concepts and Principles

Development

Overview

IDEs

API Explorer

Inputs and Outputs of a Service

Similar to a function, all services consist of inputs and outputs. Inputs are parameters that your service uses to perform its process. Outputs, on the other hand, contain the resulting values of your service.

Adding Inputs and Outputs

Coder makes it easy to define the input and output variables of Gloop and Flux services using the Input/Output view. This view is shown by default when editing a Gloop or Flux service.

The I/O view

The I/O view

There are multiple ways to add an input or output variable. You can use hotkeys, content-assist, the add button in the I/O view toolbars, or do a right click on the Input or Output half of the view > Add.

The last two options are fairly similar in that they both bring up a context menu listing all Gloop property types available. After selecting the type of variable from the context menu, you will then be given the option to rename the property appropriately. Once you're done typing the name, press to finalize.

You can rename a property by doing a right click on it and selecting Rename from the appearing context menu. As an alternative, you can also press to toggle renaming.

Adding a new Gloop service input variable

Adding a new Gloop service input variable

Pressing while focused on the Input/Output view triggers the content-assist feature which enables the user to quickly insert a variable just by pressing keys. Aside from basic variable types, it also allows the user to pick Gloop models and array variables directly. Simply use the arrow keys to shuffle through the available types and hit to confirm your choice.

Adding a new Gloop service input variable using content-assist

Adding a new Gloop service input variable using content-assist

Furthermore, there's an alternative way to add input or output Gloop model properties: by dragging them from the Coder Navigator view to the Input/Output view.

Dragging and dropping Gloop models from the Coder Navigator

Dragging and dropping Gloop models from the Coder Navigator

Meanwhile, for Groovy services, Coder features content assist. It provides contextual code completion while typing or upon user request (tap ). Coder analyzes the possible choices from the current caret position and shows its suggestions on a popup window.

If you're writing a piece of Groovy code that is to be used with Gloop, the Input/Output view can still be used to add inputs and outputs with Gloop-specific annotations! Place the cursor in a method and as you edit the inputs and outputs in the view, Coder Studio will modify your code, format it, and optimise your imports! Just make sure the method is public static.

Adding input and outputs using Gloop-enabled Groovy editor

Unsupported by Coder Cloud

As of the moment, the I/O view cannot be used alongside Groovy services in Coder Cloud. Support is still pending.

Injecting Input Variables

When a service is made invokable via HTTP or used in an Integrate endpoint, additional input variables can be injected for further use. All you need to do is declare the input variables needed by your service and ensure they are named appropriately.

Strictly use standard variable names

TORO Integrate won't inject the values of parameters that do not have standard names.

Injectable variables will differ per endpoint type

Some endpoints add more variables than others so it's important that you are aware of the types of endpoints that will execute your code.

Injectable input variables include - but are not limited to - the following:

The process of specifying and mapping input variables depends on how the service itself is defined. The following subsections will discuss the procedures of injecting arguments in detail:

In a Gloop or Flux Service

To inject an argument in Gloop or Flux, you must declare the variable under the Input/Output view. You can use the designated hotkeys or simply do a right click, pick its type, and then rename the variable. In Gloop and Flux, the names of injectable arguments must be prepended by the $ character. From there, you can use the parameter by mapping.

The example below shows how you can obtain the HttpServletRequest object in an HTTP-invokable Gloop service:

HTTP request-logging Gloop service

HTTP request-logging Gloop service

When a Gloop or Flux service is invoked via HTTP, a proxy is used to map inputs to the service. The proxy will then handle the injection of the variables for you.

In a Groovy Script

Since Groovy scripts don't have declared inputs or outputs, TORO Integrate will place all the available data in a binding for you and execute your Groovy script with the binding giving it access to all the variables. Below is a simple piece of code that logs the HTTP request object to the Integrate logger at the info level:

1
"Hello, world! The request used to invoke me is ${request}.".info()

In a Groovy Method

Unlike Groovy scripts, Groovy methods declare their input variables; to do something similar to the above Groovy script, simply declare the variable as a parameter. The method below publishes the string to a JMS queue.

1
2
3
void helloWorld(HttpServletRequest request){
    "Hello, world! The request used to invoke me is ${request}.".publishTo('queue://my.jms.HTTPQueue')
}

Injectable Input Variables

  • Arguments that can be injected to services called by Integrate endpoints are listed and described in every endpoint type's respective page.
  • Parameters injected by Gloop steps are also discussed in each Gloop step type's page.
  • In Gloop, input variables brought by HTTP invokes are listed and described in the How HTTP Requests and Responses are Mapped in Gloop page.
  • When it comes to endpoints exposed via Groovy Spring controllers, supported @RequestMapping method arguments and return types are explained in the Spring documentation.