add placeholder for generating scraper keys
parent
3408feb619
commit
29eafb3ce7
|
@ -1443,7 +1443,7 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "ptth_core"
|
||||
version = "1.2.0"
|
||||
version = "1.3.0"
|
||||
dependencies = [
|
||||
"base64",
|
||||
"ctrlc",
|
||||
|
|
|
@ -35,4 +35,4 @@ tracing = "0.1.25"
|
|||
tracing-futures = "0.2.4"
|
||||
tracing-subscriber = "0.2.15"
|
||||
|
||||
ptth_core = { path = "../ptth_core", version = "1.2.0" }
|
||||
ptth_core = { path = "../ptth_core", version = "1.3.0" }
|
||||
|
|
|
@ -469,6 +469,19 @@ async fn handle_endless_source (gib: usize, throttle: Option <usize>)
|
|||
.body (Body::wrap_stream (ReceiverStream::new (rx)))
|
||||
}
|
||||
|
||||
async fn handle_gen_scraper_key ()
|
||||
-> Result <Response <Body>, http::Error>
|
||||
{
|
||||
let key = ptth_core::gen_key ();
|
||||
|
||||
let body = format! ("Random key: {}\n", key);
|
||||
|
||||
Response::builder ()
|
||||
.status (StatusCode::OK)
|
||||
.header ("content-type", "text/plain")
|
||||
.body (Body::from (body))
|
||||
}
|
||||
|
||||
#[instrument (level = "trace", skip (req, state, handlebars))]
|
||||
async fn handle_all (
|
||||
req: Request <Body>,
|
||||
|
@ -545,6 +558,9 @@ async fn handle_all (
|
|||
else if rest == "endless_sink" {
|
||||
Ok (error_reply (StatusCode::METHOD_NOT_ALLOWED, "Don't GET this URL, POST to it.")?)
|
||||
}
|
||||
else if rest == "gen_key" {
|
||||
Ok (handle_gen_scraper_key ().await?)
|
||||
}
|
||||
else {
|
||||
Ok (error_reply (StatusCode::NOT_FOUND, "Can't route URL")?)
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue