Server tools to backfill, tail, mirror, and verify PLC logs

400 for POSTs

could be method-not-allowed, but ehhh

+14 -4
+14 -4
src/mirror.rs
··· 2 2 use futures::TryStreamExt; 3 3 use poem::{ 4 4 EndpointExt, Error, IntoResponse, Request, Response, Result, Route, Server, get, handler, 5 - http::{StatusCode, Uri}, 5 + http::StatusCode, 6 6 listener::TcpListener, 7 7 middleware::{AddData, CatchPanic, Compression, Cors, Tracing}, 8 8 web::Data, ··· 94 94 } 95 95 96 96 #[handler] 97 - async fn nope(uri: &Uri) -> Result<impl IntoResponse> { 98 - log::info!("ha nope, {uri:?}"); 99 - Ok(()) 97 + async fn nope(Data(State { upstream, .. }): Data<&State>) -> (StatusCode, String) { 98 + ( 99 + StatusCode::BAD_REQUEST, 100 + format!( 101 + r#"{} 102 + 103 + Sorry, this server does not accept POST requests. 104 + 105 + You may wish to try upstream: {upstream} 106 + "#, 107 + logo("mirror (nope)") 108 + ), 109 + ) 100 110 } 101 111 102 112 pub async fn serve(upstream: &Url, plc: Url, bind: SocketAddr) -> std::io::Result<()> {