If you have a comment on this topic, contact Aptify Documentation. If you want to return to the Aptify Community Site, please click here.

Route Metadata

The route describes the path component of the URL that will be used to address your end point.  It does not describe any query parameters or request body parameters.  The route object can have the following properties:

Route object properties

Property Name

Value 

Comments

httpMethodA string whose value is either GET, POST, PUT, PATCH or DELETE.  

Describes the HTTP Method that should be used to invoke the end point.

segmentsAn object whose properties are the name of the segment, and values are segment objects. A route needs one or more segments.

Segment object properties

Property Name

Value 

Comments

isLiteralboolean

Determines if this route segment should be a literal value or not. When it is a literal then the framework will expect to find the name of the segment object in the path. When it is not a literal, the framework will allow any value that matches the type setting for the segment object.

typestringThe type of the segment. Literal segments should be strings. Non literal segments should be the type you expect in the URL path. Valid types are: string, long, int, decimal, float, double, bool. Typically only string and long are used. Non literal segments should have their type match the same property on the input entity definition.

Let's look at a few examples:

Sample route block - only literals
{
  "endpoints": {              
    "ExamplesGetAllProducts": {
      "route": {
        "httpMethod": "GET",
        "segments": {
          "examples": {
            "isLiteral": true,
            "type": "string"
          },
          "products": {
            "isLiteral": true,
            "type": "string"
          }
        }
      }
      //remaining metadata omitted
    }
  }
}

The above example only has literals for segments, so it would create a GET end point at /examples/product

Sample route block - with non-literals
{
  "endpoints": {              
    "ExamplesGetSingleProduct": {
      "route": {
        "httpMethod": "GET",
        "segments": {
          "examples": {
            "isLiteral": true,
            "type": "string"
          },
          "products": {
            "isLiteral": true,
            "type": "string"
          },
          "productId" : {
             "isLiteral" : false,
             "type" : "long"
          }     
        }
      }
      //remaining metadata omitted
    }
  }
}

The above example has a non-literal segment named productId that is a long.  You could issue a GET to /examples/products/1 or /example/products/20213, but you could not issue a GET to /examples/products/SampcoHat.

 

Copyright © 2014-2019 Aptify - Confidential and Proprietary