pub fn post<H, Args>(path: &str, handler: H) -> RouteBuilder<'_>Expand description
Create a new RouteBuilder for the given method and add a handler
Examples found in repository?
examples/basic.rs (line 198)
188async fn main() -> Result<(), HttpServerError> {
189 logger::init_tracing()?;
190 let state = State {
191 dir: "/Users/emil/projects/tosic-http/target/doc".to_string(),
192 };
193
194 let server = HttpServerBuilder::default()
195 .app_state(state)
196 .bind("0.0.0.0:4221")
197 //.service_method(Method::POST, "/", test_handler)
198 .route(post("/", test_handler).get(test_get))
199 //.service_method(Method::GET, "/bad", not_working)
200 .service(not_working)
201 .service(test_fn)
202 //.service(website)
203 .build()
204 .await?;
205
206 match server.serve().await {
207 Ok(_) => (),
208 Err(e) => panic!("Failed to serve: {}", e),
209 }
210
211 Ok(())
212}