From e6f20f5623bb21fecc11d5345d2577db100431b2 Mon Sep 17 00:00:00 2001 From: Thomas von Dein Date: Fri, 20 Dec 2024 23:25:19 +0100 Subject: [PATCH] add rest sample --- README.md | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/README.md b/README.md index 77d4ed9..1118b84 100644 --- a/README.md +++ b/README.md @@ -25,6 +25,7 @@ reasons: - filtering using tags - encryption of entries - templates for custom output for maximum flexibility + - includes a tiny web server, which serves a restful API **anydb** can do all the things you can do with skate: @@ -110,6 +111,20 @@ anydb ls -m template -T "{{ .Value }}" eval $(anydb get foo -m template -T "key='{{ .Key }}' value='{{ .Value }}' ts='{{ .Created}}'") echo "$key: $value" +# run the restful api server +anydb serve + +# post a new key +curl -X PUT localhost:8787/anydb/v1/ \ + -H 'Content-Type: application/json' \ + -d '{"key":"foo","val":"bar"}' + +# retrieve it +curl localhost:8787/anydb/v1/foo + +# list keys +curl localhost:8787/anydb/v1/ + # it comes with a manpage builtin anydb man ```