Compare commits
2 commits
70818931aa
...
b3274f1a2a
Author | SHA1 | Date | |
---|---|---|---|
|
b3274f1a2a | ||
|
8f6c4ac81a |
4 changed files with 74 additions and 0 deletions
21
server/.gitignore
vendored
Normal file
21
server/.gitignore
vendored
Normal 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
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