Compare commits
2 commits
bf627f6003
...
32f0ed27a7
Author | SHA1 | Date | |
---|---|---|---|
32f0ed27a7 | |||
cab6b92c52 |
3 changed files with 23 additions and 30 deletions
|
@ -6,9 +6,20 @@ edition = "2021"
|
|||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
||||
[dependencies]
|
||||
# Compiling actix-server v2.2.0
|
||||
# Compiling actix-http v3.3.1
|
||||
# Compiling actix-web v4.3.1
|
||||
actix-web ="4"
|
||||
utoipa = { version = "3", features = ["actix_extras"] }
|
||||
|
||||
# Compiling actix-rt v2.8.0
|
||||
actix-rt = "*"
|
||||
|
||||
#actix-swagger = "*"
|
||||
serde = "*"
|
||||
#utoipa = { version = "3", features = ["actix_extras"] }
|
||||
# Compiling utoipa-swagger-ui v3.1.4
|
||||
utoipa-swagger-ui = { version = "3", features = ["actix-web"] }
|
||||
|
||||
[[bin]]
|
||||
name = "webserver"
|
||||
path = "web.rs"
|
||||
path = "main.rs"
|
||||
|
|
10
backend/main.rs
Normal file
10
backend/main.rs
Normal file
|
@ -0,0 +1,10 @@
|
|||
HttpServer::new(move || {
|
||||
App::new()
|
||||
.service(
|
||||
SwaggerUi::new("/swagger-ui/{_:.*}")
|
||||
.url("/api-docs/openapi.json", ApiDoc::openapi()),
|
||||
)
|
||||
})
|
||||
.bind((Ipv4Addr::UNSPECIFIED, 8000)).unwrap()
|
||||
.run();
|
||||
|
|
@ -1,28 +0,0 @@
|
|||
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
|
||||
}
|
Loading…
Reference in a new issue