MXS-1220: Add self links to all resources
A self link to the resource itself provides a convenient way for the client to request a resource, modify it and call the self link to update it. This removes some of the burden on the client to keep track of the resource links by placing these in the resource itself.
This commit is contained in:

committed by
Markus Mäkelä

parent
ac7ec04af1
commit
50eafe19fe
@ -21,6 +21,7 @@
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <fcntl.h>
|
||||
#include <string>
|
||||
|
||||
#include <maxscale/config.h>
|
||||
#include <maxscale/service.h>
|
||||
@ -45,6 +46,8 @@ using maxscale::Semaphore;
|
||||
using maxscale::Worker;
|
||||
using maxscale::WorkerTask;
|
||||
|
||||
using std::string;
|
||||
|
||||
/** The latin1 charset */
|
||||
#define SERVER_DEFAULT_CHARSET 0x08
|
||||
|
||||
@ -1456,9 +1459,14 @@ json_t* server_to_json(const SERVER* server, const char* host)
|
||||
|
||||
json_object_set_new(rval, "statictics", stats);
|
||||
|
||||
/** Store server relations to other objects */
|
||||
/** Store relationships to other objects */
|
||||
json_t* rel = json_object();
|
||||
|
||||
string self = host;
|
||||
self += "/servers/";
|
||||
self += server->unique_name;
|
||||
json_object_set_new(rel, CN_SELF, json_string(self.c_str()));
|
||||
|
||||
json_t* arr = service_relations_to_server(server, host);
|
||||
|
||||
if (json_array_size(arr) > 0)
|
||||
|
Reference in New Issue
Block a user