-
Notifications
You must be signed in to change notification settings - Fork 1
API Status Message
I realized we merged this in but there is very limited documentation on how to put a status message in the API /status
route, so here’s the quick rundown:
The data is stored in a hash in redis under the key process.env.REDIS_NAMESPACE
+ status-message
. For this example, REDIS_NAMESPACE
is going to be api-prod:
.
The /status
route will return an empty object if there is no has set in redis. Otherwise, it will return a data object reflecting exactly what is in redis. There is one special key, statusCode
that will change the response’s status code away from 200 if you set it.
To remove the status message from the /status
route, simply delete (DEL
) the entire key.
In redis:
> hset api-prod:status-message statusCode 418
> hset api-prod:status-message message “Yes, I’m a teapot”
This will produce the following response from the API:
GET /status
Code: 418
Body:
{
“statusCode”: “418”,
“message”: “Yes, I’m a teapot”
}
Or, alternatively:
In redis:
> hset api-prod:status-message message “Planned maintenance on Tuesday”
This will produce the following response from the API:
GET /status
Code: 200
Body:
{
“message”: “Planned maintenance on Tuesday”
}