No description
  • Go 90.5%
  • Makefile 5.3%
  • Dockerfile 4.2%
Find a file
2023-09-24 09:57:05 +03:00
.github/workflows allow workflow to write package 2023-09-22 23:18:33 +03:00
pkg unified response messages format, added version to api 2023-09-24 01:07:23 +03:00
config.db run make target 2023-09-24 01:29:38 +03:00
Dockerfile push image to github 2023-09-22 22:57:32 +03:00
go.mod unified response messages format, added version to api 2023-09-24 01:07:23 +03:00
go.sum unified response messages format, added version to api 2023-09-24 01:07:23 +03:00
LICENSE init commit 2023-09-13 01:05:11 +03:00
main.go unified response messages format, added version to api 2023-09-24 01:07:23 +03:00
Makefile run make target 2023-09-24 01:29:38 +03:00
README.md Update README.md 2023-09-24 09:57:05 +03:00

Description

a Simple central config server backed by bbolt with support of callbacks when a property is update.

API

Server has 3 APIs to put, get, and register webhooks:

Add/Update Property
curl -X 'POST' \
  'localhost:8080/v1/put' \
  -H 'Content-Type: application/json' \
  -d '{
  "namespace": "ns1",
  "key": "key1",
  "value": "val1"
}'

Would return {"message": "property updated"} in case of success, 400 response for missing parameters, 500 in case of a server error

Read Property
curl "localhost:8080/v1/get?key=key1&namespace=ns1"

would return {"value":"val1"} in case key1 is set in namespace ns1, 400 response for missing parameters, 500 in case of a server error

Register webhook
curl -H "Content-Type: application/json" -d '{"namespace":"ns1","key":"key1","callback":"http://localhost:8080/ping"}' -X POST localhost:8080/v1/webhook

would return {"message":"callback registered"} when callback registers successfully, 400 for missing parameters, 500 in case of internal server error callbacks can be registered even before a property is set, after registering it whenever the property value changes the callback url is called

Running the app

There is a make target for running it locally, simple execute make run and it would start it with the default port 8080. You can also use the docker image ghcr.io/shadi/simple_config:latest, it accepts environment variables Port where you can set the port the web server listens to and GIN_MODE where you can set it to RELEASE or DEBUG