WSOptions
In order to retrieve the HTTP request methods supported by the server or the resource, you define the WSOptions attribute.
Syntax
WSOptions
Usage
You use this attribute to specify the action of the HTTP verb OPTIONS to return the methods
allowed by the server or resource. You set the WSOptions
attribute in the
ATTRIBUTES()
clause of the function.
Example using WSOptions to return the methods allowed for a resource
PUBLIC FUNCTION OptionsUsers()
ATTRIBUTE(WSOptions,
WSPath = '/users')
RETURNS(STRING ATTRIBUTE(WSHeader,
WSName = "Access-Control-Allow-Methods"))
DEFINE ret STRING
LET ret = "GET, HEAD, OPTIONS, TRACE"
RETURN ret
END FUNCTION
In this example the REST function returns the supported methods in the
Access-Control-Allow-Methods
header.
Example using WSOptions to return the methods allowed for Web service
PUBLIC FUNCTION OptionsServer()
ATTRIBUTE(WSOptions,
WSPath = '/*')
RETURNS(STRING ATTRIBUTE(WSHeader,
WSName = "Access-Control-Allow-Methods"))
DEFINE ret STRING
LET ret = "GET, PUT, POST, DELETE, PATCH, HEAD, OPTIONS, TRACE"
RETURN ret
END FUNCTION
In this example the function returns the methods allowed for the entire Web
service. The client calls the above function using an asterisk (*
) in the path.http://myhost:6394/gas/ws/r/myGroup/myXcf/MyService/*