Compare commits

...

2 commits

Author SHA1 Message Date
Frank Denzer
b3274f1a2a amend gitignore for server 2023-07-16 15:19:20 +02:00
Frank Denzer
8f6c4ac81a start server project 2023-07-16 15:15:47 +02:00
4 changed files with 74 additions and 0 deletions

21
server/.gitignore vendored Normal file
View file

@ -0,0 +1,21 @@
Cargo.lock
target/
guide/build/
/gh-pages
*.so
*.out
*.pyc
*.pid
*.sock
*~
.DS_Store
# These are backup files generated by rustfmt
**/*.rs.bk
# Configuration directory generated by CLion
.idea
# Configuration directory generated by VSCode
.vscode

10
server/Cargo.toml Normal file
View 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
View 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
View 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
}