WSGet
In order to retrieve a resource, you set the WSGet attribute.
Syntax
WSGet
Usage
You use this attribute to specify the action of the HTTP verb GET to return data from a resource.
You set the WSGet
attribute in the ATTRIBUTES()
clause of the
function.
Example using WSGet to return a user record
TYPE profileType RECORD
id INT,
name VARCHAR(50),
email VARCHAR(100)
END RECORD
PUBLIC FUNCTION getUserProfile(
id STRING ATTRIBUTE(WSParam) )
ATTRIBUTES (WSGet,
WSPath="/users/{id}",
WSDescription="Returns a user profile",
WSThrows="404:user not found" )
RETURNS (profileType ATTRIBUTE(WSName="data") )
DEFINE data profileType
# ... function code ...
RETURN data.*
END FUNCTION
In this example the REST function gets the specified user record. The resource URL is
http://host:port/gas/ws/r/xcf/users/xxx
where
xxx
is the user id replaced in the 4GL function.