mirror of https://github.com/mastodon/flodgatt
Add api/v1/streaming/health API endpoint (#74)
This commit is contained in:
parent
bf529a901b
commit
597d024b8f
|
@ -2,7 +2,6 @@ use crate::from_env_var;
|
|||
use std::{
|
||||
fmt,
|
||||
net::{IpAddr, Ipv4Addr},
|
||||
os::unix::net::UnixListener,
|
||||
str::FromStr,
|
||||
time::Duration,
|
||||
};
|
||||
|
@ -35,12 +34,9 @@ from_env_var!(
|
|||
from_env_var!(
|
||||
/// A Unix Socket to use in place of a local address
|
||||
let name = Socket;
|
||||
let default: Option<UnixListener> = None;
|
||||
let (env_var, allowed_values) = ("SOCKET", "a valid Unix Socket".to_string());
|
||||
let from_str = |s| match UnixListener::bind(s).ok() {
|
||||
Some(socket) => Some(Some(socket)),
|
||||
None => None,
|
||||
};
|
||||
let default: Option<String> = None;
|
||||
let (env_var, allowed_values) = ("SOCKET", "any string".to_string());
|
||||
let from_str = |s| Some(Some(s.to_string()));
|
||||
);
|
||||
from_env_var!(
|
||||
/// The time between replies sent via WebSocket
|
||||
|
|
|
@ -5,7 +5,7 @@ use flodgatt::{
|
|||
};
|
||||
use log::warn;
|
||||
use std::{collections::HashMap, env, net};
|
||||
use warp::{ws::Ws2, Filter as WarpFilter};
|
||||
use warp::{path, ws::Ws2, Filter};
|
||||
|
||||
fn main() {
|
||||
dotenv::from_filename(
|
||||
|
@ -87,9 +87,11 @@ fn main() {
|
|||
|
||||
let server_addr = net::SocketAddr::new(*cfg.address, cfg.port.0);
|
||||
|
||||
let health = warp::path!("api" / "v1" / "streaming" / "health").map(|| "OK");
|
||||
|
||||
if let Some(_socket) = cfg.unix_socket.0.as_ref() {
|
||||
dbg_and_die!("Unix socket support not yet implemented");
|
||||
} else {
|
||||
warp::serve(websocket_routes.or(sse_routes).with(cors)).run(server_addr);
|
||||
warp::serve(health.or(websocket_routes.or(sse_routes).with(cors))).run(server_addr);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue