You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
33 lines
700 B
33 lines
700 B
//! For API calls if enabled
|
|
use super::*;
|
|
use std::{
|
|
iter,
|
|
convert::Infallible,
|
|
};
|
|
use futures::{
|
|
stream::{
|
|
self,
|
|
BoxStream,
|
|
StreamExt,
|
|
},
|
|
};
|
|
pub mod error;
|
|
use error::ApiError;
|
|
|
|
mod single;
|
|
|
|
#[inline] fn aggregate(mut body: impl Buf) -> Result<String, std::str::Utf8Error>
|
|
{
|
|
std::str::from_utf8(&body.to_bytes()).map(ToOwned::to_owned)
|
|
}
|
|
|
|
pub async fn single(host: IpAddr, num: Option<usize>, body: impl Buf) -> Result<impl warp::Reply, warp::reject::Rejection>
|
|
{
|
|
single::single_stream(host, num, body).await
|
|
.map(|rx| Response::new(Body::wrap_stream(rx.map(move |x| {
|
|
info!("{} <- {:?}", host, x);
|
|
x
|
|
}))))
|
|
.map_err(warp::reject::custom)
|
|
}
|