Rest Api Endpoint

Rest Api Endpoint nodes create endpoints for receiving HTTP requests. They must be placed inside a Rest Api node.

When requests are received a message is output to a connected Function node. Only one Function node may be connected to the output port. The connected Function node returns a response to be sent back for the HTTP request.

Message Formats

Stackery enables integration between AWS API Gateway methods and AWS Lambda functions using Lambda Proxy Integration. This mechanism supports rich and dynamic HTTP request/response handling.

Output

When an HTTP request is received, the Rest Api Endpoint node outputs a message containing all the details of the request. Here is an overview of commonly used request properties:

Field Type Description
httpMethod string Method of the request. Example: GET
resource string Resource endpoint matching the path of the request. Example: /users/{id}
pathParameters Object Map of resource parameter values. Example: {"id": "5"}
queryStringParameters Object Map of query string parameter values. Example: {"admin": "true"}
headers Object Map of request header values. Example: {"Host": "stacks.stackery.io", "Accept": "application/json"}
body Buffer Request body.
requestContext.sourceIp string IP Address of requesting client. Example: 38.182.58.3
requestContext.requestId string Request ID as a GUID. Example: a0a5150b-a050-11e6-895a-159872556d76


See https://docs.aws.amazon.com/apigateway/latest/developerguide/set-up-lambda-proxy-integrations.html#api-gateway-simple-proxy-for-lambda-input-format for further details on the input message format.

Expected Response

The response message from the connected Function node contains the HTTP response information. Here is an overview of commonly used response properties:

Field Type Default Description
statusCode number (required) Status code of the response. Example: 202
headers Object {} Map of response header values. Example: {"Content-Type": "text/html", "Access-Control-Allow-Origin": "example.com"}
body Buffer or string null Body of response. Example: {"name": "bob"}


See https://docs.aws.amazon.com/apigateway/latest/developerguide/set-up-lambda-proxy-integrations.html#api-gateway-simple-proxy-for-lambda-output-format for further details on the response message format.

Settings

Name

A label for the node in the canvas.

Endpoint

A specification for the paths that will be handled by this request node. The value can define a single path, a path with resource parameters, and/or a wildcard (*).

Examples:

/users
/users/{id}
/users/{id}/{property}
/users/{id}/emails/{email}
/users/{id}/locations/*

When a request matches an endpoint with resource parameters, the value of the parameters will be provided in the resourceParams field of the request message. For example, a request made to /users/5/locations/US/OR/97205/9584-Oak-Leaf-Rd would have the following request message fields:

{
  ...
  "pathname": "/users/5/locations/US/OR/97205/9584-Oak-Leaf-Rd",
  "endpoint": "/users/{id}/locations/*",
  "resourceParams": {
    "id": "5",
    "*": "US/OR/97205/9584-Oak-Leaf-Rd"
  }
}

Referenceable Properties

The following properties may be referenced by Function, Docker Service, and Docker Task nodes:

Property Value Example
path Endpoint /path/to/resource

Try Stackery For Free

Gain control and visibility of your serverless operations from architecture design to application deployment and infrastructure monitoring.