Add a simple /health endpoint which all Otto services should have
This commit is contained in:
parent
8be8dc98d7
commit
d5303133e8
|
@ -21,6 +21,18 @@ servers:
|
|||
- url: 'http://localhost:7672'
|
||||
description: 'Local dev server'
|
||||
paths:
|
||||
'/health':
|
||||
get:
|
||||
operationId: GetHealth
|
||||
description: |
|
||||
The health endpoint helps indicate whether the service is healthy or not.
|
||||
Any non-200 response is unhealthy.
|
||||
responses:
|
||||
'200':
|
||||
description: 'A successful healthcheck'
|
||||
content:
|
||||
application/json: {}
|
||||
|
||||
'/v1/parse':
|
||||
post:
|
||||
operationId: ParsePipeline
|
||||
|
|
|
@ -57,12 +57,17 @@ async fn parse(mut req: Request<()>) -> tide::Result {
|
|||
Ok(Response::builder(422).content_type("application/json").build())
|
||||
}
|
||||
|
||||
async fn healthcheck(_req: Request<()>) -> tide::Result {
|
||||
Ok(Response::builder(200).body("{}").content_type("application/json").build())
|
||||
}
|
||||
|
||||
|
||||
#[async_std::main]
|
||||
async fn main() -> Result<(), std::io::Error> {
|
||||
use std::{env, net::TcpListener, os::unix::io::FromRawFd};
|
||||
tide::log::start();
|
||||
let mut app = tide::new();
|
||||
app.at("/health").get(healthcheck);
|
||||
app.at("/v1/parse").post(parse);
|
||||
|
||||
if let Some(fd) = env::var("LISTEN_FD").ok().and_then(|fd| fd.parse().ok()) {
|
||||
|
|
Loading…
Reference in New Issue