C++17 implementation of Varasto server.
$ git submodule update --init
$ mkdir build
$ cd build
$ cmake ..
$ makeCreate directory where the data will stored into, then launch varasto-server
with the directory as argument, such as:
$ mkdir data
$ varasto-server ./dataBy default port 8080 will be used. This can be overridden with -p switch.
To store an item, you can use a POST request like this:
POST /foo/bar HTTP/1.0
Content-Type: application/json
Content-Length: 14
{"foo": "bar"}Or you can use curl to store an item like this:
$ curl -X POST \
-H 'Content-Type: application/json' \
-d '{"foo": "bar"}' \
http://localhost:8080/foo/barIf you want an key to the entry to be automatically generated (it will be UUID) you can omit the key from the request like this:
POST /foo HTTP/1.0
Content-Type: application/json
Content-Length: 14
{"foo": "bar"}And you get an response like this that contains the automatically generated key:
{ "key": "13aa0984-af0f-11ef-a02b-2743ddb77e05" }To retrieve a previously stored item, you make an GET request, where the
request path again acts as the identifier of the item.
GET /foo/bar HTTP/1.0To which the HTTP server will respond with the JSON object previously stored
with namespace foo and key bar. If an item with given key under the given
namespace does not exist, HTTP error 404 will be returned instead.
To list all items stored under an namespace, you make an GET request with
name of the namespace as the request path.
GET /foo HTTP/1.0To which the HTTP server will respond with an JSON object which contains each item stored under namespace foo mapped with the key that they were stored with.
{
"bar": {
"foo": "bar"
}
}To remove an previously stored item, you make a DELETE request with the
request path again acting as the identifier of the item you wish to remove.
DELETE /foo/bar HTTP/1.0If item with key bar under namespace foo exists, it's value will be returned as response. If such item does not exist, HTTP error 404 will be returned instead.
To remove all entries stored under an namespace, you make a DELETE request
with the request path acting as identifier of the namespace you wish to remove.
DELETE /foo HTTP/1.0If an namespace with the given identifier exists, an object containing all the entries that existed in the namespace will be returned as response. If such namespace does not exist, HTTP error 404 will be returned instead.
You can also partially update an already existing item with PATCH request.
The JSON sent with an PATCH request will be shallowly merged with the already
existing data and the result will be sent as response.
For example, you have an item john-doe under namespace people with the following data:
{
"name": "John Doe",
"address": "Some street 4",
"phoneNumber": "+35840123123"
}And you send an PATCH request like this:
PATCH /people/john-doe HTTP/1.0
Content-Type: application/json
Content-Length: 71
{
"address": "Some other street 5",
"faxNumber": "+358000000"
}You end up with:
{
"name": "John Doe",
"address": "Some other street 5",
"phoneNumber": "+35840123123",
"faxNumber": "+358000000"
}- Caching.
- SSL support.
- Basic authentication support.