Skip to content

Commit ca77e16

Browse files
committed
Add .well-known/check endpiont
Signed-off-by: Leonardo Cecchi <[email protected]>
1 parent 75fec56 commit ca77e16

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ Environment variables are your friends:
1515
* `SQL_QUERY` is the SQL query that will be executed when accessing the `/tx`
1616
endpoint.
1717

18+
The endpoint `/.well-known/check` will always return "ok".
1819

1920
## Other considerations
2021

http_test.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
#include <libpq-fe.h>
2121

2222
void tx(const httplib::Request &req, httplib::Response &res);
23+
void ok(const httplib::Request &req, httplib::Response &res);
2324
void logger(const httplib::Request &req, const httplib::Response &res);
2425
std::string get_configuration(const std::string &env_name,
2526
const std::string &default_value = "");
@@ -42,6 +43,7 @@ int main() {
4243
// Starting HTTP server
4344
httplib::Server svr;
4445
svr.Get("/tx", tx);
46+
svr.Get("/.well-known/check", ok);
4547
svr.listen("0.0.0.0", 8080);
4648

4749
return 0;
@@ -122,6 +124,15 @@ void tx(const httplib::Request &req, httplib::Response &res) {
122124
PQfinish(conn);
123125
}
124126

127+
/**
128+
* The test transaction on PostgreSQL
129+
*/
130+
void ok(const httplib::Request &req, httplib::Response &res) {
131+
RequestHandlerLogger _logger(req, res);
132+
res.status = 200;
133+
res.set_content("Ok!", "text/plain");
134+
}
135+
125136
/**
126137
* Get a configuration parameter or returns the default value
127138
*/

0 commit comments

Comments
 (0)