kvstore provides key-value storage over HTTP.
Usage:
kvstore [FLAG]...
Do NOT use to store your secrets.
go get -u github.com/peteretelej/kvstore
Create a json file (creds.json) containing a list of accepted credentials/keys that clients will use when getting or setting values.
# create credentials file (json array of strings/credentials)
echo '["credential1","cred2"]' >creds.json
# launches the kvstore store listening on port 8080
kvstore
Changing server listen address and credentials
# launch store on localhost (local kvstore)
kvstore -listen localhost:8080
# use a diffent file instead of creds.json
kvstore -creds ~/.kvcreds.json
Clients can interact with the kvstore server through:
- the command line (kvstore cli)
- HTTP Requests
PUT
andGET
A client needs to set the environment variables
$KVSTORE
with the store endpoint$KVCRED
with one of the creds increds.json
Use the -set
and get
flags to set and retrieve values.
# export store server endpoint and cred
export KVSTORE=http://localhost:8080
export KVCRED=credential1
# set key value hello=world
kvstore -set -k "hello" -v "world"
# get the value for key hello
kvstore -get -k "hello"
Setting key-value:
Use PUT
request with url form/query values:
cred
: one of the values increds.json
k
: the key to be setv
: the value to be set
URL example: PUT http://localhost:8080?cred=credential1&k=hello&v=world
Retrieving a value:
Use GET
request with the following
cred
: one of the values increds.json
k
: the key whose value you want
URL example: GET http://localhost:8080?cred=credential1&k=hello