Skip to content
DRAFT

HTTP API Gateway

Bondy API Gateway is a reverse proxy that lets you manage, configure, and route requests to your WAMP APIs and also to external HTTP/REST APIs. It allows Bondy to be integrated into an existing HTTP/REST API ecosystem.

API

The following http api is used to configure and manage the Gateway Specification:

NameHTTP MethodURL
Get an API SpecGET/api_specs/:id
Get info an API SpecGET/api_specs/:id/info
List all API SpecsGET/api_specs
Load an API SpecPOST/api_specs
Load an API SpecPOST/services/load_api_spec

API Get

It allows to retrieve the requested api spec id.

This endpoint is useful for example to be entirely sure to check if the api spec definition was properly loaded and activated.

bash
curl -X "GET" "http://localhost:18081/api_specs/com.market.demo" \
-H 'Content-Type: application/json; charset=utf-8' | jq
json
{
  "defaults": {
    "connect_timeout": 5000.00000000000000000,
    "headers": "{{variables.cors_headers}}",
    "retries": 0E-20,
    "schemes": "{{variables.schemes}}",
    "security": "{{variables.oauth2}}",
    "timeout": 15000.0000000000000000
  },
  "host": "_",
  "id": "com.market.demo",
  "meta": {},
  "name": "Marketplace Demo API",
  "realm_uri": "com.market.demo",
  "status_codes": {
    "com.example.error.internal_error": 500.000000000000000000,
    "com.example.error.not_found": 404.000000000000000000,
    "com.example.error.unknown_error": 500.000000000000000000
  },
  "ts": -576459578303,
  "variables": {},
  "versions": {}
}

Errors

  • bondy.error.not_found: when the provided api spec id is not found.
json
{
  "code": "bondy.error.not_found",
  "description": "",
  "message": ""
}

API Get Info

It allows to retrieve the info (some attributes) of the requested api spec id.

bash
curl -X "GET" "http://localhost:18081/api_specs/com.market.demo/info" \
-H 'Content-Type: application/json; charset=utf-8' | jq
json
{
  "host": "_",
  "id": "com.market.demo",
  "meta": {},
  "name": "Marketplace Demo API",
  "realm_uri": "com.market.demo",
  "ts": -576459578303
}

Errors

  • bondy.error.not_found: when the provided api spec id is not found.
json
{
  "code": "bondy.error.not_found",
  "description": "",
  "message": ""
}

API List

It allows to retrieve the all loaded apis spec.

bash
curl -X "GET" "http://localhost:18081/api_specs" \
-H 'Content-Type: application/json; charset=utf-8' | jq
json
[
  {
    "defaults": {
      "connect_timeout": 5000,
      "headers": "{{variables.headers}}",
      "retries": 0,
      "schemes": "{{variables.schemes}}",
      "security": "{{variables.oauth2}}",
      "timeout": 5000
    },
    "host": "_",
    "id": "com.leapsight.test",
    "name": "Test API",
    "realm_uri": "com.leapsight.test",
    "status_codes": {
      "bondy.error.already_exists": 400,
      "bondy.error.badarg": 400,
      "bondy.error.no_such_user": 400,
      "bondy.error.not_found": 404
    },
    "ts": -576460749718,
    "variables": {
      "headers": {
        "access-control-allow-credentials": "true",
        "access-control-allow-headers": "origin,x-requested-with,content-type,accept",
        "access-control-allow-methods": "GET,HEAD,PUT,PATCH,POST,DELETE",
        "access-control-allow-origin": "*",
        "access-control-max-age": "86400"
      },
      "oauth2": {
        "flow": "resource_owner_password_credentials",
        "revoke_token_path": "/oauth/revoke",
        "schemes": "{{variables.schemes}}",
        "token_path": "/oauth/token",
        "type": "oauth2"
      },
      "schemes": [
        "http",
        "https"
      ],
      "wamp_error_body": "{{action.error.kwargs |> put(code, {{action.error.error_uri}})}}"
    },
    "versions": {
      "1.0.0": {
        "base_path": "/[v1.0]",
        "defaults": {
          "timeout": 20000
        },
        "languages": [
          "en"
        ],
        "paths": {
          "/services/call": {
            "description": "",
            "is_collection": false,
            "options": {
              "action": {},
              "response": {
                "on_error": {
                  "body": ""
                },
                "on_result": {
                  "body": ""
                }
              }
            },
            "post": {
              "action": {
                "args": "{{request.body.args}}",
                "kwargs": "{{request.body.kwargs}}",
                "options": "{{request.body.options}}",
                "procedure": "{{request.body.procedure}}",
                "type": "wamp_call"
              },
              "response": {
                "on_error": {
                  "body": {
                    "args": "{{action.error.args}}",
                    "details": "{{action.error.details}}",
                    "error_uri": "{{action.error.error_uri}}",
                    "kwargs": "{{action.error.kwargs}}"
                  },
                  "status_code": "{{status_codes |> get({{action.error.error_uri}}, 500) |> integer}}"
                },
                "on_result": {
                  "body": {
                    "args": "{{action.result.args}}",
                    "details": "{{action.result.details}}",
                    "kwargs": "{{action.result.kwargs}}"
                  }
                }
              }
            },
            "summary": "Allows to perform an arbitrary WAMP call."
          }
        },
        "variables": {}
      }
    }
  },
  {
    "defaults": {
      "connect_timeout": 5000.00000000000000000,
      "headers": "{{variables.cors_headers}}",
      "retries": 0E-20,
      "schemes": "{{variables.schemes}}",
      "security": "{{variables.oauth2}}",
      "timeout": 15000.0000000000000000
    },
    "host": "_",
    "id": "com.market.demo",
    "meta": {},
    "name": "Marketplace Demo API",
    "realm_uri": "com.market.demo",
    "status_codes": {
      "com.example.error.internal_error": 500.000000000000000000,
      "com.example.error.not_found": 404.000000000000000000,
      "com.example.error.unknown_error": 500.000000000000000000
    },
    "ts": -576459578303,
    "variables": {},
    "versions": {}
  }
]

Errors

API Load

The following command will load the API Specification, validate it and if successful it will be compiled and activate it.

Note

There are two endpoints you can use to load the api spec definition with the same behaviour:

  • /services/load_api_spec
  • /api_specs
bash
curl -X "POST" "http://localhost:18081/api_specs" \
-H 'Content-Type: application/json; charset=utf-8' \
-H 'Accept: application/json; charset=utf-8' \
--data-binary "@my_api.json"
bash
curl -X "POST" "http://localhost:18081/services/load_api_spec" \
-H 'Content-Type: application/json; charset=utf-8' \
-H 'Accept: application/json; charset=utf-8' \
--data-binary "@my_api.json"

Errors

  • wamp.error.invalid_argument: when there is an invalid number of positional arguments.
json
{
  "code": "wamp.error.invalid_argument",
  "description": "",
  "message": "There is no realm named 'com.example.my_api'"
}

Except where otherwise noted, content on this site is licensed under a Creative Commons Attribution-ShareAlike (CC-BY-SA) 4.0 International license.
Bondy and Leapsight are registered trademarks of Leapsight Technologies Ltd.