tangled
alpha
login
or
join now
ptr.pet
/
Allegedly
forked from
microcosm.blue/Allegedly
0
fork
atom
Server tools to backfill, tail, mirror, and verify PLC logs
0
fork
atom
overview
issues
pulls
pipelines
400 for POSTs
could be method-not-allowed, but ehhh
bad-example.com
5 months ago
63a68056
6975ff0a
+14
-4
1 changed file
expand all
collapse all
unified
split
src
mirror.rs
+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
5
-
http::{StatusCode, Uri},
5
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
97
-
async fn nope(uri: &Uri) -> Result<impl IntoResponse> {
98
98
-
log::info!("ha nope, {uri:?}");
99
99
-
Ok(())
97
97
+
async fn nope(Data(State { upstream, .. }): Data<&State>) -> (StatusCode, String) {
98
98
+
(
99
99
+
StatusCode::BAD_REQUEST,
100
100
+
format!(
101
101
+
r#"{}
102
102
+
103
103
+
Sorry, this server does not accept POST requests.
104
104
+
105
105
+
You may wish to try upstream: {upstream}
106
106
+
"#,
107
107
+
logo("mirror (nope)")
108
108
+
),
109
109
+
)
100
110
}
101
111
102
112
pub async fn serve(upstream: &Url, plc: Url, bind: SocketAddr) -> std::io::Result<()> {