Location Http Service

Once the Location server is up and running, it can be used to access the following:

Register a connection

Register
POST http://localhost:7654/post-endpoint
Content-Type: application/json

{
  "Register": {
    "HttpRegistration": {
      "connection": {
        "prefix": "csw.server",
        "componentType": "service",
        "connectionType": "http"
      },
      "port": 1234,
      "path": "root/path1"
    }
  }
}
###
200 Ok
HTTP/1.1 200 OK
Server: akka-http/10.1.11
Date: Mon, 30 Dec 2019 11:49: 56 GMT
Content-Type: application/json
Content-Length: 151

{
  "HttpLocation": {
    "connection": {
      "prefix": "csw.service",
      "componentType": "service",
      "connectionType": "http"
    },
    "uri": "http://192.168.5.105:1234/root/path1"
  }
}

###

Re-register same connection

Re-register same connection
POST http://localhost:7654/post-endpoint
Content-Type: application/json

{
  "Register": {
    "HttpRegistration": {
      "connection": {
        "prefix": "csw.server",
        "componentType": "service",
        "connectionType": "http"
      },
      "port": 1235,
      "path": "root/path1"
    }
  }
}
###
500 Internal server error
HTTP/1.1 500 Internal Server Error
Server: akka-http/10.1.11
Date: Mon, 30 Dec 2019 12: 04: 34 GMT
Content-Type: application/json
Content-Length: 207

{
  "OtherLocationIsRegistered": "there is another location=HttpLocation(HttpConnection(ComponentId(csw.service,Service)),http://192.168.5.105:1235/root/path1) registered against name=csw.service-service-http."
}

###

Malformed Request

Malformed Request
POST http://localhost:7654/post-endpoint
Content-Type: application/json

{
  "Register": {
    "HttpRegistration": {
      "connection": {
        "prefix": "csw.server",
        "componentType": "service",
        "connectionType": "http"
      },
      "path": "root/path1"
    }
  }
}
###
400 Bad Request
HTTP/1.1 400 Bad Request
Server: akka-http/10.1.11
Date: Mon, 30 Dec 2019 12: 06: 43 GMT
Content-Type: text/plain; charset=UTF-8
Content-Length: 127

The request content was malformed: Cannot decode `HttpRegistration` instance due to missing map key "port" (input position 208)

###

Unregister a connection

Unregister
POST http://localhost:7654/post-endpoint
Content-Type: application/json

{
  "Unregister": {
    "prefix": "csw.server",
    "componentType": "service",
    "connectionType": "http"
  }
}
###
200 Ok
HTTP/1.1 200 OK
Server: akka-http/10.1.11
Date: Tue, 31 Dec 2019 04:46:30 GMT
Content-Type: application/json
Content-Length: 6

"done"

###

Find a location

Find
POST http://localhost:7654/post-endpoint
Content-Type: application/json

{
  "Find": {
    "prefix": "csw.server",
    "componentType": "service",
    "connectionType": "http"
  }
}

###
200 Ok
HTTP/1.1 200 OK
Server: akka-http/10.1.11
Date: Tue, 31 Dec 2019 04: 45: 18 GMT
Content-Type: application/json
Content-Length: 152

[
  {
    "HttpLocation": {
      "connection": {
        "prefix": "csw.server",
        "componentType": "service",
        "connectionType": "http"
      },
      "uri": "http://192.168.5.105:1234/root/path1"
    }
  }
]

###

Resolve a location

Resolve
POST http://localhost:7654/post-endpoint
Content-Type: application/json

{
  "Resolve": {
    "connection": {
      "prefix": "csw.server",
      "componentType": "service",
      "connectionType": "http"
    },
    "within": "5 seconds"
  }
}

###
200 Ok
HTTP/1.1 200 OK
Server: akka-http/10.1.11
Date: Tue, 31 Dec 2019 04: 44: 09 GMT
Content-Type: application/json
Content-Length: 152

{
  "HttpLocation": {
    "connection": {
      "prefix": "csw.server",
      "componentType": "service",
      "connectionType": "http"
    },
    "uri": "http://192.168.5.105:1234/root/path1"
  }
}

###

List all locations

List
POST http://localhost:7654/post-endpoint
Content-Type: application/json

{
  "ListEntries": {}
}

###
200 Ok
HTTP/1.1 200 OK
Server: akka-http/10.1.11
Date: Tue, 31 Dec 2019 04:52:23 GMT
Content-Type: application/json
Content-Length: 152

[
  {
    "HttpLocation": {
      "connection": {
        "prefix": "csw.server",
        "componentType": "service",
        "connectionType": "http"
      },
      "uri": "http://192.168.5.105:1234/root/path1"
    }
  }
]

###

List all locations by component type

List by component type
POST http://localhost:7654/post-endpoint
Content-Type: application/json

{
  "ListByComponentType": "service"
}

###
200 Ok
HTTP/1.1 200 OK
Server: akka-http/10.1.11
Date: Tue, 31 Dec 2019 04:56:52 GMT
Content-Type: application/json
Content-Length: 152

[
  {
    "HttpLocation": {
      "connection": {
        "prefix": "csw.server",
        "componentType": "service",
        "connectionType": "http"
      },
      "uri": "http://192.168.5.105:1234/root/path1"
    }
  }
]

###

List all locations by hostname

List by hostname
POST http://localhost:7654/post-endpoint
Content-Type: application/json

{
  "ListByHostname": "192.168.5.105"
}

###
200 Ok
HTTP/1.1 200 OK
Server: akka-http/10.1.11
Date: Tue, 31 Dec 2019 04:57:48 GMT
Content-Type: application/json
Content-Length: 152

[
  {
    "HttpLocation": {
      "connection": {
        "prefix": "csw.server",
        "componentType": "service",
        "connectionType": "http"
      },
      "uri": "http://192.168.5.105:1234/root/path1"
    }
  }
]

###

List all locations by connection type

List by connection type
POST http://localhost:7654/post-endpoint
Content-Type: application/json

{
  "ListByConnectionType": "http"
}

###
200 Ok
HTTP/1.1 200 OK
Server: akka-http/10.1.11
Date: Tue, 31 Dec 2019 04:59:54 GMT
Content-Type: application/json
Content-Length: 152

[
  {
    "HttpLocation": {
      "connection": {
        "prefix": "csw.server",
        "componentType": "service",
        "connectionType": "http"
      },
      "uri": "http://192.168.5.105:1234/root/path1"
    }
  }
]

###

List all locations by prefix

List by prefix
POST http://localhost:7654/post-endpoint
Content-Type: application/json

{
  "ListByPrefix": "csw.server"
}

###
200 Ok
HTTP/1.1 200 OK
Server: akka-http/10.1.11
Date: Tue, 31 Dec 2019 05:00:38 GMT
Content-Type: application/json
Content-Length: 152

[
  {
    "HttpLocation": {
      "connection": {
        "prefix": "csw.server",
        "componentType": "service",
        "connectionType": "http"
      },
      "uri": "http://192.168.5.105:1234/root/path1"
    }
  }
]

###

Unregister all connections

Unregister all
POST http://localhost:7654/post-endpoint
Content-Type: application/json

{
  "UnregisterAll": {}
}

###
200 Ok
HTTP/1.1 200 OK
Server: akka-http/10.1.11
Date: Tue, 31 Dec 2019 05:00:58 GMT
Content-Type: application/json
Content-Length: 6

"done"

###

Track a connection

Track (Websocket)

ws://localhost:7654/websocket-endpoint

{
  "Track": {
    "prefix": "csw.server",
    "componentType": "service",
    "connectionType": "http"
  }
}

Responses

Location Updated

{
  "LocationUpdated": {
    "location": {
      "HttpLocation": {
        "connection": {
          "prefix": "csw.server",
          "componentType": "service",
          "connectionType": "http"
        },
        "uri": "http://192.168.5.105:1234/root/path1"
      }
    }
  }
}

Location Removed

{
  "LocationRemoved": {
    "connection": {
      "prefix": "csw.server",
      "componentType": "service",
      "connectionType": "http"
    }
  }
}
Note

One can use websocket plugin for IntelliJ or chrome extension to test the track functionality of location service.

Note

All the requests to location server can result in 400 Bad Request or 500 Internal Server error

Source code for examples

Note

The location.http has first class support to execute http requests directly from IDEs like IntelliJ IDEA provided location server is already running.