forked from mgl_crew/Mitgliederladen
start server project
This commit is contained in:
parent
70818931aa
commit
8f6c4ac81a
3 changed files with 53 additions and 0 deletions
10
server/Cargo.toml
Normal file
10
server/Cargo.toml
Normal file
|
@ -0,0 +1,10 @@
|
|||
[package]
|
||||
name = "server"
|
||||
version = "1.0.0"
|
||||
edition = "2021"
|
||||
|
||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
||||
[dependencies]
|
||||
actix-web ="4"
|
||||
utoipa = { version = "3", features = ["actix_extras"] }
|
15
server/readme.md
Normal file
15
server/readme.md
Normal file
|
@ -0,0 +1,15 @@
|
|||
# installation
|
||||
|
||||
## windows (step 1)
|
||||
|
||||
choco install -y
|
||||
|
||||
## Linux, macos (alernate step 1)
|
||||
|
||||
use apt, pacman, curl, brew or whatever.
|
||||
|
||||
## Always (steps 2 and so on)
|
||||
|
||||
- `rustup-init.sh` (Windows: rustup-init.ex, e.g. %AppData%\Local\Temp\chocolatey\rustup.install\1.25.1\rustup-init.exe)
|
||||
- select a good match in the dialog of this CLI installer
|
||||
|
28
server/src/main.rs
Normal file
28
server/src/main.rs
Normal file
|
@ -0,0 +1,28 @@
|
|||
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