From the REST service to the proxy

The delegation REST service must notify the dispatcher when it approves the start of an application or service.

Approve the proxy start

To approve the start of an application or a service proxy or the service forwarding (because if it is a web service using delegation, the service may be already started), the Genero REST service must return the following HTTP code and description: The HTTP return code must be 307 and the description must be the string _GENERO_INTERNAL_DELEGATE_.

Returning this HTTP code and description notifies the dispatcher to start the application or service proxy as the response to the current user-agent request.

IMPORT com
DEFINE req com.HTTPServiceRequest
...
CALL req.sendResponse(307,"_GENERO_INTERNAL_DELEGATE_")
...
Note: You can return a body from the REST service that is then transmitted to the proxy if original incoming request was POST or PUT, otherwise body is skipped.

Passing parameters to the proxy

When you need to pass additional parameters to a starting proxy, you can do it via environment variables that are then set in a gwc or gdc proxy environment before the dispatcher starts it. Each parameter must be set in the HTTP header response when you specify the 307 HTTP return code. The HTTP header name must be of the form X-FourJs-Environment-XXX where XXX is the name of the variable to pass to the proxy and as HTTP header value, the value of the environment variable. Then, with a call to the Genero function fgl_getenv(), you can retrieve them in your Genero program.

Passing parameters to a proxy is not possible for Web services requests, as the proxy is already started. The only way to send the environment with a Web services request is through the HTTP header.
REST sample:
IMPORT com
DEFINE req com.HTTPServiceRequest
...
CALL req.setResponseHeader("X-FourJs-Environment-Hello","World")
CALL req.setResponseHeader("X-FourJs-Environment-Name","Georges")
CALL req.sendResponse(307,"_GENERO_INTERNAL_DELEGATE_")
...
Genero program sample:
MAIN
...
DISPLAY fgl_getenv("Hello")  -- Displays "World"
DISPLAY fgl_getenv("Name")   -- Displays "Georges"
...