1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
//! Support for the [`axum`] web server framework in wasi-http components, via
//! [`wstd`].
//!
//! This crate is a pretty thin wrapper on [`wstd`] that allows users to
//! use the [`axum`] crate on top of wstd's http support. This means that
//! axum services can run anywhere the [wasi-http proxy world] is supported,
//! e.g. in [`wasmtime serve`].
//!
//! Users of this crate should depend on `axum` with `default-features =
//! false`, and opt in to any features that they require (e.g. form, json,
//! matched-path, original-uri, query, tower-log, tracing). The axum crate
//! features that require `hyper` or `tokio` are NOT supported (e.g. http1,
//! http2, ws), because unlike in native applications, wasi-http components
//! have an http implementation provided as imported interfaces (i.e.
//! implemented the Wasm host), and do not use raw sockets inside of this
//! program.
//!
//! # Examples
//!
//! The simplest use is via the `wstd_axum::http_server` proc macro.
//! This macro can be applied to a sync or `async` `fn main` which returns
//! an impl of the `tower_service::Service` trait, typically an
//! `axum::Router`:
//!
//! ```rust,no_run
//! ```
//!
//! If users desire, they can instead use a `wstd::http_server` entry point
//! and then use `wstd_axum::serve` directly. The following is equivelant
//! to the above example:
//!
//! ```rust,no_run
//! ```
//!
//! [`axum`]: https://docs.rs/axum/latest/axum/
//! [`wstd`]: https://docs.rs/wstd/latest/wstd/
//! [wasi-http proxy world]: https://github.com/WebAssembly/wasi-http
//! [`wasmtime serve`]: https://wasmtime.dev/
use Request;
use Response;
use Infallible;
use Service;
pub use attr_macro_http_server as http_server;
pub async