summaryrefslogtreecommitdiff
path: root/actix/src
diff options
context:
space:
mode:
Diffstat (limited to 'actix/src')
-rw-r--r--actix/src/main.rs30
1 files changed, 30 insertions, 0 deletions
diff --git a/actix/src/main.rs b/actix/src/main.rs
new file mode 100644
index 0000000..4f03d08
--- /dev/null
+++ b/actix/src/main.rs
@@ -0,0 +1,30 @@
+
+use actix_web::{get, post, web, App, HttpResponse, HttpServer, Responder};
+
+#[get("/")]
+async fn hello() -> impl Responder {
+ HttpResponse::Ok().body("Hello world!")
+}
+
+#[post("/echo")]
+async fn echo(req_body: String) -> impl Responder {
+ HttpResponse::Ok().body(req_body)
+}
+
+async fn manual_hello() -> impl Responder {
+ HttpResponse::Ok().body("Hey there!")
+}
+
+#[actix_web::main]
+async fn main() -> std::io::Result<()> {
+ HttpServer::new(|| {
+ App::new()
+ .service(hello)
+ .service(echo)
+ .route("/hey", web::get().to(manual_hello))
+ })
+ .bind("127.0.0.1:8080")?
+ .run()
+ .await
+}
+