Categorygithub.com/project-flogo/contrib/trigger/rest
modulepackage
0.10.0
Repository: https://github.com/project-flogo/contrib.git
Documentation: pkg.go.dev

# README

REST Trigger

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

Installation

flogo install github.com/project-flogo/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/project-flogo/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/project-flogo/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"
            }
          }
        }
      ]
    }
  ]
}

# Packages

Cors package to validate CORS requests and provide the correct headers in the response.

# Functions

No description provided by the author
Timeouts options lets you set the read and write timeouts of the server.
TLS option enables TLS on the server.

# Constants

No description provided by the author
No description provided by the author

# Structs

No description provided by the author
No description provided by the author
IDResponse id response object.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
Trigger REST trigger struct.