rest

package
v0.5.2-rc3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 15, 2018 License: BSD-3-Clause Imports: 18 Imported by: 0

README

tibco-rest

This trigger provides your flogo application the ability to start a flow via REST over HTTP

Installation

flogo add trigger github.com/TIBCOSoftware/flogo-contrib/trigger/rest

Schema

Settings, Outputs and Endpoint:

{
  "settings": [
    {
      "name": "port",
      "type": "integer"
    }
  ],
  "output": [
    {
      "name": "pathParams",
      "type": "params"
    },
    {
      "name": "queryParams",
      "type": "params"
    },
    {
      "name": "header",
      "type": "params"
    },
    {
      "name": "content",
      "type": "object"
    }
  ],
  "endpoint": {
    "settings": [
      {
        "name": "method",
        "type": "string",
        "required" : true
      },
      {
        "name": "path",
        "type": "string",
        "required" : true
      }
    ]
  }
}

Settings

Trigger:
Setting Description
port The port to listen on
Endpoint:
Setting Description
method The HTTP method
path The resource path

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": [
    {
      "name": "tibco-rest",
      "settings": {
        "port": "8080"
      },
      "endpoints": [
        {
          "actionType": "flow",
          "actionURI": "embedded://new_device_flow",
          "settings": {
            "method": "POST",
            "path": "/device"
          }
        }
      ]
    }
  ]
}
GET

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

{
  "triggers": [
    {
      "name": "tibco-rest",
      "settings": {
        "port": "8080"
      },
      "endpoints": [
        {
          "actionType": "flow",
          "actionURI": "embedded://get_device_flow",
          "settings": {
            "method": "GET",
            "path": "/device/:id"
          }
        }
      ]
    }
  ]
}

Documentation

Index

Constants

View Source
const (
	REST_CORS_PREFIX = "REST_TRIGGER"
)

Variables

This section is empty.

Functions

func NewFactory

func NewFactory(md *trigger.Metadata) trigger.Factory

NewFactory create a new Trigger factory

Types

type IDResponse

type IDResponse struct {
	ID string `json:"id"`
}

IDResponse id response object

type RestFactory

type RestFactory struct {
	// contains filtered or unexported fields
}

RestFactory REST Trigger factory

func (*RestFactory) New

func (t *RestFactory) New(config *trigger.Config) trigger.Trigger

New Creates a new trigger instance for a given id

type RestTrigger

type RestTrigger struct {
	// contains filtered or unexported fields
}

RestTrigger REST trigger struct

func (*RestTrigger) Init

func (t *RestTrigger) Init(runner action.Runner)

func (*RestTrigger) Initialize added in v0.5.2

func (t *RestTrigger) Initialize(ctx trigger.InitContext) error

func (*RestTrigger) Metadata

func (t *RestTrigger) Metadata() *trigger.Metadata

Metadata implements trigger.Trigger.Metadata

func (*RestTrigger) Start

func (t *RestTrigger) Start() error

func (*RestTrigger) Stop

func (t *RestTrigger) Stop() error

Stop implements util.Managed.Stop

type Server

type Server struct {
	*http.Server
	// contains filtered or unexported fields
}

Server the server structure

func NewServer

func NewServer(addr string, handler http.Handler) *Server

NewServer create a new server instance param server - is a instance of http.Server, can be nil and a default one will be created

func (*Server) InstanceID

func (s *Server) InstanceID() string

InstanceID the server instance id

func (*Server) IsStarted

func (s *Server) IsStarted() bool

IsStarted checks if the server is started will return true even if the server is stopped but there are still some requests to finish

func (*Server) Start

func (s *Server) Start() error

Start this will start server command isn't blocking, will exit after run

func (*Server) Stop

func (s *Server) Stop() error

Stop sends stop command to the server

func (*Server) WaitStop

func (s *Server) WaitStop(timeout time.Duration) error

WaitStop waits until server is stopped and all requests are finish timeout - is the time to wait for the requests to finish after the server is stopped will return error if there are still some requests not finished

Directories

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

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL