"restis", composed from "REST" and "Redis", is a simple HTTP API to get / set / delete Redis keys
Find a file
Knut Ahlers 4b9090edd8
Initial version
Signed-off-by: Knut Ahlers <knut@ahlers.me>
2022-12-27 18:16:50 +01:00
.gitignore Initial version 2022-12-27 18:16:50 +01:00
Dockerfile Initial version 2022-12-27 18:16:50 +01:00
go.mod Initial version 2022-12-27 18:16:50 +01:00
go.sum Initial version 2022-12-27 18:16:50 +01:00
LICENSE Initial version 2022-12-27 18:16:50 +01:00
main.go Initial version 2022-12-27 18:16:50 +01:00
README.md Initial version 2022-12-27 18:16:50 +01:00
rest.go Initial version 2022-12-27 18:16:50 +01:00

Luzifer / restis

restis, composed from REST and Redis, is a simple HTTP API to get / set / delete Redis keys.

Q&A

  • Why?
    Previously I used a kyototycoon to store simple key-value-data through a REST interface but needed something not using a proprietary database format below it to have it running statelessly in a cluster. Searching for some alternative I gave up and invested 20 minutes in putting together this.
  • Is there any security built in?
    No. And it never will be. Don't expose it without securing it for example using nginx-sso or Gatekeeper or whatever. This is just a simple API, you're responsible for the rest.

Usage

# restis --help
Usage of restis:
      --listen string              Port/IP to listen on (default ":3000")
      --log-level string           Log level (debug, info, warn, error, fatal) (default "info")
      --redis-conn-string string   Connection string for redis (default "redis://localhost:6379/0")
      --redis-key-prefix string    Prefix to prepend to keys (will be prepended without delimiter!)
      --version                    Prints current version and exits
# curl -fX GET localhost:3000/mykey
curl: (22) The requested URL returned error: 404

# echo "mycontent" | curl -fX PUT --data-binary @- localhost:3000/mykey

# curl -fX GET localhost:3000/mykey
mycontent

# curl -fX DELETE localhost:3000/mykey

# curl -fX GET localhost:3000/mykey
curl: (22) The requested URL returned error: 404

# echo "mycontent" | curl -fX PUT --data-binary @- localhost:3000/mykey\?expire=30s

# curl -fX GET localhost:3000/mykey
mycontent

# sleep 30; curl -fX GET localhost:3000/mykey
curl: (22) The requested URL returned error: 404