wasmer_wasix/runners/
mod.rs1mod runner;
2
3#[cfg(feature = "webc_runner_rt_dcgi")]
4pub mod dcgi;
5#[cfg(feature = "webc_runner_rt_dproxy")]
6pub mod dproxy;
7pub mod wasi;
8mod wasi_common;
9#[cfg(feature = "webc_runner_rt_wcgi")]
10pub mod wcgi;
11
12#[cfg(any(feature = "webc_runner_rt_wcgi", feature = "webc_runner_rt_dproxy"))]
13mod body {
14 use http_body_util::{BodyExt, Full, combinators::BoxBody};
15
16 pub type Body = BoxBody<bytes::Bytes, anyhow::Error>;
17
18 pub fn body_from_data(data: impl Into<bytes::Bytes>) -> Body {
19 BoxBody::new(Full::new(data.into()).map_err(|_| -> anyhow::Error { unreachable!() }))
20 }
21
22 pub fn body_from_stream<S>(s: S) -> Body
23 where
24 S: futures::stream::Stream<Item = Result<hyper::body::Frame<bytes::Bytes>, anyhow::Error>>
25 + Send
26 + Sync
27 + 'static,
28 {
29 BoxBody::new(http_body_util::StreamBody::new(s))
30 }
31}
32
33#[cfg(any(feature = "webc_runner_rt_wcgi", feature = "webc_runner_rt_dproxy"))]
34pub use self::body::*;
35
36pub use self::{
37 runner::Runner,
38 wasi_common::{
39 MAPPED_CURRENT_DIR_DEFAULT_PATH, MappedCommand, MappedDirectory, MountedDirectory,
40 },
41};
42
43#[cfg(any(feature = "webc_runner_rt_wcgi", feature = "webc_runner_rt_dproxy"))]
47mod response_tracing {
48 use tower_http::trace::OnResponse;
49
50 #[derive(Clone, Copy)]
51 pub struct OnResponseTracer;
52
53 impl<B> OnResponse<B> for OnResponseTracer {
54 fn on_response(
55 self,
56 response: &http::Response<B>,
57 _latency: std::time::Duration,
58 span: &tracing::Span,
59 ) {
60 span.record("status_code", tracing::field::display(response.status()));
61 tracing::info!("response generated")
62 }
63 }
64}