| Crates.io | netron |
| lib.rs | netron |
| version | 0.3.0 |
| created_at | 2023-03-22 15:17:58.773219+00 |
| updated_at | 2025-11-26 10:39:36.420967+00 |
| description | Extract Axum request data within Yew server functions similar to how `leptos_axum` provides extraction helpers for Leptos |
| homepage | |
| repository | https://github.com/netrondev/netron |
| max_upload_size | |
| id | 817224 |
| size | 160,602 |
use netron::prelude::*;
// GET EXAMPLE
#[axumhandler(method = "GET", path = "/api/hello")]
pub async fn hello_world() -> Result<String, AppError> {
Ok("world!".to_string())
}
// POST EXAMPLE
#[derive(Serialize, Debug, Deserialize, Clone)]
struct FooBar {
name: String,
count: u32,
}
#[axumhandler(method = "POST", path = "/api/foo")]
pub async fn test_sending(input: FooBar) -> Result<String, AppError> {
println!("{:#?}", input);
Ok("world!".to_string())
}
// MAIN SERVER
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
dotenvy::dotenv().ok();
server_main().await?;
Ok(())
}
# curl -sL localhost:4000/api/hello
"world!"
curl -X POST http://localhost:4000/api/foo -H "Content-Type: application/json" -d '{"input": {"name": "rouan", "count": 40 }}'
Server console:
2025-11-26T10:34:30.624989Z INFO http_request{method=POST uri=/api/foo version=HTTP/1.1}: netron::server: API call: POST /api/foo
FooBar {
name: "rouan",
count: 40,
}
2025-11-26T10:34:30.625154Z INFO http_request{method=POST uri=/api/foo version=HTTP/1.1}: netron::server: Response: status=200 OK latency=240.772µs