Actix-gym-training
Rust & Actix Web exploration. Set up of an application that records the series and repetitions of a sports session
Database
In the past I did a quick test by doing a synchronous implementation : gym-schedule with Diesel
In this second iteration I would like to explore another option: async db adapters
https://github.com/prisma/quaint
Async Options
We have several example projects showing use of async database adapters:
-
SQLx: https://github.com/actix/examples/tree/master/sqlx_todo
-
Postgres: https://github.com/actix/examples/tree/master/async_pg
-
SQLite: https://github.com/actix/examples/tree/master/async_db
-
Test SQLx
-
Test async_pg
-
Test SQLite
Features
Documentation
Example
Request:
curl http://localhost:8080/xxxxxxx
Code:
use actix_web::{get, post, web, App,Error, HttpResponse, HttpServer, Responder};
#[get("/")]
async fn hello() -> impl Responder {
HttpResponse::Ok().body("Hello world! πππ").with_header("Content-type", "text/html; charset=utf-8")
}
#[post("/echo")]
async fn echo(req_body: String) -> impl Responder {
HttpResponse::Ok().body(req_body)
}
#[actix_web::main]
async fn main() -> std::io::Result<()> {
HttpServer::new(|| {
App::new()
.service(hello)
.service(echo)
.service(stream)
.route("/hey", web::get().to(manual_hello))
})
.bind("127.0.0.1:8080")?
.run()
.await
}