RestServerApp

REST Server Application Configuration

The N2SVCD REST Server Application listens for inbound REST.

The REST Server Application does not process any user content itself. It exists only as an agent to receive requests on behalf of another application.

Typical uses of the RestClientApp are:

See the N2SVCD Configuration Overview for more information on how the REST Server Application interacts with other components.

The following configuration is used to create a REST Application TCP Server instance.

<?xml version="1.0" encoding="utf-8"?>
<n2svcd>
  ...
  <applications>
    ...
    <application name="REST-SERVER" module="RestServerApp">
      <include><lib>../apps/rest_s/lib</lib></include>
      <parameters>
        <parameter name="trace_level" value="1"/>
        <parameter name="local_port" value="8118"/>
      </parameters>
      <config>
        <handlers>
          <handler method="GET" application="Logic"/>
        </handlers>
      </config>
    </application>
    ...
  </application>
  ...
</n2svcd>

Configuration Details

The application element attributes for a REST Server Application instance may include the below.

For details of the various parameter types used, refer to Common Configuration.

Parameter Name Type XML Type Description
See: Common Application configuration
See: TCP Application configuration
module String Attribute [Required] RestServerApp
include.lib String Element [Required] ../apps/rest_s/lib
parameters Array Element [Required] As per Common Configuration Application parameters.
"edr_enabled" - - This value is ignored; the REST Server Application Application does not support writing EDRs.
"socket_mode" String Attribute The REST Server Application supports only listen (TCP Client).
(Default = listen)
"local_port" Positive Integer Attribute As per common TCP configuration for local_port.
(Default = 8080)
"ping_interval" - - This value is ignored; the REST Client Application does not support ping messages.
config Object Element Container for extended configuration for this application.
.handlers Array Element Array of handler elements, rules for selecting the owning Application for inbound REST requests.

REST Handlers

Handler rules define which application is used to process inbound REST Requests. Each handler Object in the config.handlers Array is configured as follows.

Parameter Name Type XML Type Description
method String Attribute The inbound HTTP method, e.g. GET, PUT, POST, DELETE, etc.
(Default = Handle all methods)
path String Attribute A path from the URL, exact matched against the path of the inbound request. Only one of path or path_prefix may be specified.
path_prefix String Attribute A path from the URL, prefix matched against the path of the inbound request. Only one of path or path_prefix may be specified.
application String Attribute [Required] The name of the application that should process matching messages. This will normally refer to a LogicApp instance.

The handlers will be checked in order, and the first matching handler will be used.

Message Handling

In addition to the common Application management messages, the RestClientApp uses the following messages: