Skip to content

REST API

Yaroslav Pogrebnyak edited this page Jun 25, 2016 · 12 revisions

Table of Contents

Configuration

You can enable/disable and configure REST API port in gobetween config file in [api] section:

[api]

enabled = true  # true | false
bind = ":8888"  # bind host:port

Errors

API responds with typical HTTP codes representing success of failure of the operation:

  • 200 OK
  • 400 Bad Request
  • 409 Conflict
  • 500 Internal Server Error

REST API Specification

General

GET / - System Information

Returns system information about gobetween process.

Response
{
    "configPath": String,
    "pid": Integer,
    "startTime": String,
    "time": String,
    "uptime": Duration,
    "version": String
}

GET /dump - Dump Current Config in TOML Format

Response
 # TOML formatted text of current config 

Servers

GET /servers/<name> - Get Server By Name

Response
{
   // server definition of the same structure and format as `[servers.<name>]` 
   // entry in config TOML file but JSON encoded.
}

GET /servers - List All Servers

Response
{
    // Represents the same structure and format as `[servers]` entries in config TOML file.

    "<name>": {
        // server definition of the same structure and format as `[servers.<name>]` 
        // entry in config TOML file but JSON encoded.
    },

    // other servers

}

POST /servers/<name> - Create Server With Name <name>

Body
{
   // server definition of the same structure and format as `[servers.<name>]` 
   // entry in config TOML file but JSON encoded.
}

DELETE /servers/<name> - Delete Server