mirror of
https://github.com/actix/examples
synced 2024-11-27 16:02:57 +01:00
Run rustfmt
This commit is contained in:
parent
8f1c0a85cf
commit
046604f286
@ -98,8 +98,7 @@ mod handlers {
|
||||
) -> Result<HttpResponse, Error> {
|
||||
let user_info: User = user.into_inner();
|
||||
|
||||
let client: Client =
|
||||
db_pool.get().await.map_err(MyError::PoolError)?;
|
||||
let client: Client = db_pool.get().await.map_err(MyError::PoolError)?;
|
||||
|
||||
let new_user = db::add_user(&client, user_info).await?;
|
||||
|
||||
|
@ -1,7 +1,9 @@
|
||||
use actix_web::{web, App, HttpRequest, HttpResponse, HttpServer, client::{Client, Connector}};
|
||||
use actix_web::{
|
||||
client::{Client, Connector},
|
||||
web, App, HttpRequest, HttpResponse, HttpServer,
|
||||
};
|
||||
use openssl::ssl::{SslConnector, SslMethod};
|
||||
|
||||
|
||||
async fn index(_req: HttpRequest) -> HttpResponse {
|
||||
let builder = SslConnector::builder(SslMethod::tls()).unwrap();
|
||||
|
||||
@ -21,21 +23,19 @@ async fn index(_req: HttpRequest) -> HttpResponse {
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
println!("awc time elapsed while reading bytes into memory: {} ms", now.elapsed().as_millis());
|
||||
println!(
|
||||
"awc time elapsed while reading bytes into memory: {} ms",
|
||||
now.elapsed().as_millis()
|
||||
);
|
||||
|
||||
HttpResponse::Ok()
|
||||
.content_type("image/jpeg")
|
||||
.body(payload)
|
||||
HttpResponse::Ok().content_type("image/jpeg").body(payload)
|
||||
}
|
||||
|
||||
#[actix_rt::main]
|
||||
async fn main() -> std::io::Result<()> {
|
||||
let port = 3000;
|
||||
|
||||
HttpServer::new(|| {
|
||||
App::new()
|
||||
.service(web::resource("/").to(index))
|
||||
})
|
||||
HttpServer::new(|| App::new().service(web::resource("/").to(index)))
|
||||
.bind(("0.0.0.0", port))?
|
||||
.run()
|
||||
.await
|
||||
|
@ -19,11 +19,7 @@ async fn again() -> impl Responder {
|
||||
async fn main() -> std::io::Result<()> {
|
||||
println!("Starting actix-web server");
|
||||
|
||||
HttpServer::new(|| {
|
||||
App::new()
|
||||
.service(index)
|
||||
.service(again)
|
||||
})
|
||||
HttpServer::new(|| App::new().service(index).service(again))
|
||||
.bind("0.0.0.0:5000")?
|
||||
.run()
|
||||
.await
|
||||
|
@ -33,8 +33,7 @@ impl User {
|
||||
fn products(&self, context: &Context) -> Vec<Product> {
|
||||
let mut conn = context.dbpool.get().unwrap();
|
||||
|
||||
conn
|
||||
.prep_exec(
|
||||
conn.prep_exec(
|
||||
"select * from product where user_id=:user_id",
|
||||
params! {
|
||||
"user_id" => &self.id
|
||||
|
@ -2,7 +2,6 @@ use actix_web::{get, middleware, post, web, App, HttpResponse, HttpServer};
|
||||
use futures::executor;
|
||||
use std::{sync::mpsc, thread};
|
||||
|
||||
|
||||
#[get("/hello")]
|
||||
async fn hello() -> &'static str {
|
||||
"Hello world!"
|
||||
|
Loading…
Reference in New Issue
Block a user