Skip to content

Latest commit

 

History

History
118 lines (92 loc) · 1.8 KB

README.md

File metadata and controls

118 lines (92 loc) · 1.8 KB

Redis REST API

Run

docker run -d -p 8080:8080 redis-rest:latest

Structure

type RedisDataModel struct {
Key    string `json:"key"`
Value  string    `json:"value"`
Expire int    `json:"expire" default:"0"`
}

Details

Key Types Description Value Default
key string Key string *
Value string Value string *
Expire int Time for Expired int (second) 0: non expired

* : required

Get Version

API Endpoint
GET /v1/version
Request

curl -L -X GET 'localhost:8080/v1/version'

Respond
{
  "success": true,
  "message": "Version 1.0.0"
}

GET KEY

API Endpoint
GET /v1/keys/:key
Request

curl -L -X GET 'localhost:8080/v1/keys/:keyexample'

Respond
{
  "success": true,
  "message": "Get key from Redis server",
  "data": {
    "key": "keyexample",
    "value": "1",
    "expire": 0
  }
}

PUT KEY

API Endpoint
PUT /v1/keys
Request
curl -L -X PUT 'localhost:8080/v1/keys' 
--header 'Content-Type: application/json' 
--data '{
"key": "keyexample",
"value": 1,
"expire": 10
}'
Respond
{
  "success": true,
  "message": "Put key to Redis server",
  "data": {
    "key": "keyexample",
    "value": 1,
    "expire": 10
  }
}

DELETE KEY

API Endpoint
DELETE /v1/keys/keyexample
Request
`curl -L -X DELETE 'localhost:8080/v1/keys/:keyexample'`
Respond
{
  "success": true,
  "message": "Delete key from Redis server"
}