use actix_htmx::{Htmx, HtmxMiddleware, TriggerType}; use actix_web::{web, App, HttpResponse, HttpServer, Responder}; #[actix_web::main] async fn main() -> std::io::Result<()> { HttpServer::new(|| { App::new() .wrap(HtmxMiddleware) .service(web::resource("/contact/1/edit").to(index)) }) .bind("0.0.0.0:8080")? .run() .await } async fn index(htmx: Htmx) -> impl Responder { let mut body: &str = "did not work"; if htmx.is_htmx { body = r#"
"# } htmx.trigger_event( "my_event".to_string(), Some(r#"{"level": "info", "message": "my event message!"}"#.to_string()), Some(TriggerType::Standard) ); HttpResponse::Ok().content_type("text/html").body(body) }