With this API, an inmemory key value store can be used using endpoints. Endpoints are described in API Doc. The key value store is saved in a JSON file every minute under temp. When the API starts working, if there is already a JSON file, the data in this file is saved in memory.
-
Go v1.17.3 or higher -> Go Installation Page
-
Docker v3.3.2 or higher (optional) -> Docker Get Started Page
Before starting the application, fork/download/clone this repo.
- To run the application on localhost:8000:
docker-compose up --build
- Description: The key's value returns in response.
GET Request to '/api/get?key=foo' endpoint. //Foo means name of key, desired value can be entered.
{
"key": "foo",
"value": "bar",
"status": "OK"
}
If the key is not used:
{
"message": "Bad Request. The URL may be an incorrect or there may not be a value for the key value."
}
Status Code | HTTP Meaning | API Meaning |
---|---|---|
200 | Success | The value of the key was searched |
400 | Bad Request | URL, JSON structure or request method is wrong |
- Description: Creates new key-value pair.
{
"pair": [
{
"key": "foo",
"value": "bar"
},
{
"key": "yemek",
"value": "sepeti"
}
]
}
{
"pair": [
{
"key": "foo",
"value": "bar",
"status": "Saved."
},
{
"key": "yemek",
"value": "sepeti",
"status": "Saved."
}
]
}
If the key-value store is already used.
{
"pair": [
{
"key": "foo",
"value": "bar",
"status": "Key not saved. It was used or one of the tags is wrong."
},
{
"key": "yemek",
"value": "sepeti",
"status": "Key not saved. It was used or one of the tags is wrong."
}
]
}
Status Code | HTTP Meaning | API Meaning |
---|---|---|
201 | Created | The key-value pair created |
400 | Bad Request | URL, JSON structure or request method is wrong |
- Description: Returns information about all key-values.
GET Request to '/api/get-all'
{
"foo": "bar",
"yemek": "sepeti"
}
If there is no key-value pair.
{
"status": "There is no pair."
}
Status Code | HTTP Meaning | API Meaning |
---|---|---|
200 | Success | Provided information about all key/value pairs |
400 | Bad Request | Request method is wrong |
- Description: Deletes key-value pair.
GET Request to '/api/delete?key=foo'
{
"status": "The key is deleted"
}
If there is no key-value pair:
{
"message": "Bad Request. The URL may be an incorrect or there may not be a value for the key value."
}
Status Code | HTTP Meaning | API Meaning |
---|---|---|
200 | Success | The desired key-value pair has been deleted |
400 | Bad Request | Request method is wrong or the key is not using |
- Description: Deletes all key-value pairs.
GET Request to '/api/flush' endpoint.
{
"status": "All datas are deleted"
}
Status Code | HTTP Meaning | API Meaning |
---|---|---|
200 | Success | All pairs deleted |
400 | Bad Request | Wrong request method |
|