Specifies a path to a REST Web service resource that identifies its function and allows parameters to be passed in the URL.


WSPath = "/{ path-element | value-template } [/...]"
where path-element is an identifier:
and where value-template is an identifier enclosed in curly brackets:
  1. path-element is a slash-separated list of path elements.
  2. value-template elements are place holders for a slash-separated list of variable values.

WSPath is an optional attribute.

If there is no WSPath specified, the function name (case sensitive) is the path to the resource in the URI.


You use this attribute to set the resource identifier or endpoint of the URI to the resource. For example, a path to the "users" URI resource is specified as follows:

The WSPath string begins with a slash (/), and there is a slash between each path element and/or template value.

If you need to specify a resource within a collection, such as a specific user identified by ID, and when a pattern could match many similar resources, it is specified with a path template.

The path template is an identifier enclosed in curly brackets {}. Zero, one, or several path templates can be specified. Values are substituted when a GWS client makes a call to the resource.

Path template values are provided at runtime in function parameters which have WSParam attributes. As many template values as path templates must be specified. In other words there must be a function parameter with a WSParam attribute to match each template path. fglcomp checks to ensure that there is one template value per parameter, otherwise compilation error-9111 is thrown.

You set the WSPath attribute in the ATTRIBUTES() clause of the function.

Example path templating with WSParam

In this sample REST function a user resource is returned. In the function's p_user_id parameter the attribute WSParam specifies the user to return.

The WSPath attribute sets the resource identifier or endpoint of the URI to the resource. It contains the function's p_user_id parameter enclosed in curly brackets {} as the path template.

The client application needs to provide an appropriate parameter value when making a call to the function. For example, the variable part of the path (p_user_id) is replaced by the integer value /4 in the URL:


TYPE accountType RECORD
         user_id INTEGER,
         user_name VARCHAR(50)

             WSPath = "/accounts/{p_user_id}",
             WSDescription = "Returns an account record",
             WSThrows = "404:not found"
  RETURNS accountType ATTRIBUTES(WSName = "Account",WSMedia = "application/json") 
    DEFINE p_accountRec accountType
    SELECT * INTO p_accountRec.* FROM users WHERE id = p_user_id

    RETURN p_accountRec