feat: allow discarding output completely
This commit is contained in:
parent
ee876471a6
commit
218db3a175
3 changed files with 9 additions and 3 deletions
|
@ -4,6 +4,10 @@ user_agent = "postwoman@sample/0.2.0"
|
|||
[route.healthcheck]
|
||||
url = "https://api.alemi.dev/"
|
||||
|
||||
[route.benchmark]
|
||||
url = "https://api.alemi.dev/look/into/the/void"
|
||||
extract = { type = "discard" }
|
||||
|
||||
[route.debug]
|
||||
url = "https://api.alemi.dev/debug"
|
||||
method = "PUT"
|
||||
|
|
|
@ -56,8 +56,8 @@ fn print_results(res: String, name: String, before: chrono::DateTime<chrono::Utc
|
|||
let after = chrono::Utc::now();
|
||||
let elapsed = (after - before).num_milliseconds();
|
||||
let timestamp = after.format(TIMESTAMP_FMT);
|
||||
eprintln!(" + [{timestamp}] {name} done in {elapsed}ms:", );
|
||||
println!("{}", res);
|
||||
eprintln!(" + [{timestamp}] {name} done in {elapsed}ms", );
|
||||
print!("{}", res);
|
||||
}
|
||||
|
||||
#[tokio::main]
|
||||
|
|
|
@ -150,7 +150,8 @@ impl Endpoint {
|
|||
|
||||
Ok(match self.extract.unwrap_or_default() {
|
||||
StringOr::Str(_query) => todo!(),
|
||||
StringOr::T(Extractor::Debug) => format!("{res:#?}"),
|
||||
StringOr::T(Extractor::Discard) => "".to_string(),
|
||||
StringOr::T(Extractor::Debug) => format!("{res:#?}\n"),
|
||||
StringOr::T(Extractor::Body) => res.text().await?,
|
||||
StringOr::T(Extractor::Header { key }) => res
|
||||
.headers()
|
||||
|
@ -181,6 +182,7 @@ pub enum Extractor {
|
|||
#[default]
|
||||
Debug,
|
||||
Body,
|
||||
Discard,
|
||||
// JQL { query: String },
|
||||
// Regex { pattern: String },
|
||||
Header { key: String },
|
||||
|
|
Loading…
Reference in a new issue