Categorygithub.com/open-dovetail/dovetail-contrib/trigger/rest

# Packages

No description provided by the author

# README

REST Trigger

This trigger provides your flogo application the ability to start an action via REST over HTTP

This is a fork from https://github.com/project-flogo/contrib/tree/master/trigger/rest

This version updated the descriptor.json, so app models can be imported to Flogo Enterprise when app properties are used in trigger settings.

Installation

flogo install github.com/open-dovetail/dovetail-contrib/trigger/rest

Configuration

Settings:

NameTypeDescription
portintThe port to listen on - REQUIRED
enableTLSboolEnable TLS on the server
certFilestringThe path to PEM encoded server certificate
keyFilestringThe path to PEM encoded server key

Handler Settings:

NameTypeDescription
methodstringThe HTTP method (ie. GET,POST,PUT,PATCH or DELETE) - REQUIRED
pathstringThe resource path - REQUIRED

Output:

NameTypeDescription
pathParamsparamsThe path parameters (e.g., 'id' in http://.../pet/:id/name )
queryParamsparamsThe query parameters (e.g., 'id' in http://.../pet?id=someValue )
headersparamsThe HTTP header parameters
methodstringThe HTTP method used for the request
contentanyThe content of the request

Reply:

NameTypeDescription
codeintThe http code to reply with
dataanyThe data to reply with
headersparamsThe HTTP response headers
cookiesparamsThe HTTP response cookies to set (uses 'Set-Cookie' headers)

Example Configurations

Triggers are configured via the triggers.json of your application. The following are some example configuration of the REST Trigger.

POST

Configure the Trigger to handle a POST on /device

{
  "triggers": [
    {
      "id": "flogo-rest",
      "ref": "github.com/open-dovetail/dovetail-contrib/trigger/rest",
      "settings": {
        "port": 8080
      },
      "handlers": [
        {
          "settings": {
            "method": "POST",
            "path": "/device"
          },
          "action": {
            "ref": "github.com/project-flogo/flow",
            "settings": {
              "flowURI": "res://flow:new_device_flow"
            }
          }
        }
      ]
    }
  ]
}

GET

Configure the Trigger to handle a GET on /device/:id

{
  "triggers": [
    {
      "id": "flogo-rest",
      "ref": "github.com/open-dovetail/dovetail-contrib/trigger/rest",
      "settings": {
        "port": 8080
      },
      "handlers": [
        {
          "settings": {
            "method": "GET",
            "path": "/device/:id"
          },
          "action": {
            "ref": "github.com/project-flogo/flow",
            "settings": {
              "flowURI": "res://flow:get_device_flow"
            },
            "input": {
              "deviceId": "=$.pathParams.id"
            }
          }
        }
      ]
    }
  ]
}