Spaces:
Running
Running
feat: add health check endpoint to server (#2968)
Browse files
examples/server/server.cpp
CHANGED
|
@@ -1024,6 +1024,11 @@ int main(int argc, char ** argv) {
|
|
| 1024 |
// check if the model is in the file system
|
| 1025 |
});
|
| 1026 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1027 |
svr.set_exception_handler([](const Request &, Response &res, std::exception_ptr ep) {
|
| 1028 |
const char fmt[] = "500 Internal Server Error\n%s";
|
| 1029 |
char buf[BUFSIZ];
|
|
|
|
| 1024 |
// check if the model is in the file system
|
| 1025 |
});
|
| 1026 |
|
| 1027 |
+
svr.Get(sparams.request_path + "/health", [&](const Request &, Response &res){
|
| 1028 |
+
const std::string health_response = "{\"status\":\"ok\"}";
|
| 1029 |
+
res.set_content(health_response, "application/json");
|
| 1030 |
+
});
|
| 1031 |
+
|
| 1032 |
svr.set_exception_handler([](const Request &, Response &res, std::exception_ptr ep) {
|
| 1033 |
const char fmt[] = "500 Internal Server Error\n%s";
|
| 1034 |
char buf[BUFSIZ];
|