From 6ce4b88a5a9fa5b2ed3a63bbe5ed5f7caee26d26 Mon Sep 17 00:00:00 2001 From: Mohammed Sohail Date: Tue, 14 Dec 2021 18:03:47 +0300 Subject: [PATCH] docs: add readme --- .gitignore | 1 + README.md | 15 +++++++++++++++ internal/server/router.go | 3 +-- 3 files changed, 17 insertions(+), 2 deletions(-) create mode 100644 .gitignore create mode 100644 README.md diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..a725465 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +vendor/ \ No newline at end of file diff --git a/README.md b/README.md new file mode 100644 index 0000000..c19abf0 --- /dev/null +++ b/README.md @@ -0,0 +1,15 @@ +### openethereum-node-status + +A tiny stateless service to return health status and useful metrics from OpenEthereum/Parity nodes. Requires the [following API's](https://openethereum.github.io/JSONRPC) to be enabled: + +- eth +- parity + +#### Endpoints + +- `/health` (Expect 200 for health with an additional JSON object with more info) +- `/metrics` (Expect 200 for health with an additional JSON object with more info) + +#### Development + +`DEBUG_ENABLED=true go run cmd/node-status/main.go` diff --git a/internal/server/router.go b/internal/server/router.go index e547b49..2e1ca75 100644 --- a/internal/server/router.go +++ b/internal/server/router.go @@ -24,15 +24,14 @@ func healthHandler(c *gin.Context) { fmt.Println(data.SyncComplete) if !allOk { + // choose a better status code if available c.JSON(http.StatusExpectationFailed, gin.H{ - "ok": false, "message": "could not get node health status", }) return } c.JSON(http.StatusOK, gin.H{ - "ok": true, "syncComplete": data.SyncComplete, "chainName": data.ChainName, })