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
- The HTTP return code must be
307
- 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_")
...
You can return an HTTP message body from the REST service that is then transmitted to the
proxy if the original incoming request was POST
or PUT
,
otherwise body is skipped.
Passing parameters to web applications or web services
X-FourJs-Environment-envvar:value
Where:envvar
is the name of the variable.- value is the value of the variable.
307
HTTP return code. For
example: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_")
...
These headers are returned by the service to the proxy to be parsed and added in the environment of started DVMs.
X-FourJs-Environment-Hello:World
x-fourjs-environment-hello:World
HELLO=World
where it can be retrieved.Retrieving parameters for web application
The parameters set in the Passing parameters to web applications or web services
are converted to environment variables and thus you can retrieve them in your Genero
application with a call to the Genero function
fgl_getenv(VARIABLENAME)
(the variable name must be
in uppercase)
MAIN
...
DISPLAY fgl_getenv("HELLO") -- Displays "World"
DISPLAY fgl_getenv("NAME") -- Displays "Georges"
...
Retrieving parameters for web services
In the context of the web service, the parameters set in the Passing parameters to web applications or web services can be
retrieved in your delegation service or in another web service with a call to the Genero
getRequestHeader
method of the com.HTTPServiceRequest
class.
IMPORT com
DEFINE resp com.HTTPServiceRequest
LET h1 = resp.getRequestHeader("X-FourJs-Environment-Hello")
DISPLAY h1 -- Displays "World"
LET h2 = resp.getRequestHeader("X-FourJs-Environment-Name")
DISPLAY h2 -- Displays "Georges"
...