From 9c34ded6fde3f6cab59194518ddd7a813b6148a7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Roman=20Fro=C5=82ow?= Date: Sun, 12 Jan 2020 13:11:12 +0100 Subject: [PATCH] Use derive feature from serde https://github.com/serde-rs/serde/issues/1441#issuecomment-445481084 (#230) --- simple-auth-server/Cargo.toml | 3 +-- simple-auth-server/README.md | 8 ++++++++ simple-auth-server/src/auth_handler.rs | 1 + simple-auth-server/src/invitation_handler.rs | 1 + simple-auth-server/src/main.rs | 2 -- simple-auth-server/src/models.rs | 1 + simple-auth-server/src/register_handler.rs | 1 + 7 files changed, 13 insertions(+), 4 deletions(-) diff --git a/simple-auth-server/Cargo.toml b/simple-auth-server/Cargo.toml index c9313f4f..5012515b 100644 --- a/simple-auth-server/Cargo.toml +++ b/simple-auth-server/Cargo.toml @@ -18,8 +18,7 @@ env_logger = "0.6" futures = "0.3.1" r2d2 = "0.8" lazy_static = "1.3.0" -serde = "1.0" -serde_derive = "1.0" +serde = { version = "1.0", features = ["derive"] } serde_json = "1.0" sparkpost = "0.5.2" uuid = { version = "0.7", features = ["serde", "v4"] } diff --git a/simple-auth-server/README.md b/simple-auth-server/README.md index dc25484a..19e6504e 100644 --- a/simple-auth-server/README.md +++ b/simple-auth-server/README.md @@ -28,3 +28,11 @@ Read the full tutorial series on [gill.net.in](https://gill.net.in) - [Auth Web Microservice with rust using Actix-Web 1.0 - Complete Tutorial](https://gill.net.in/posts/auth-microservice-rust-actix-web1.0-diesel-complete-tutorial/) + +## Dependencies + +On Ubuntu 19.10: + +``` +sudo apt install libclang-dev libpq-dev +``` diff --git a/simple-auth-server/src/auth_handler.rs b/simple-auth-server/src/auth_handler.rs index e2aba868..934c2b32 100644 --- a/simple-auth-server/src/auth_handler.rs +++ b/simple-auth-server/src/auth_handler.rs @@ -8,6 +8,7 @@ use actix_web::{ use diesel::prelude::*; use diesel::PgConnection; use futures::future::Future; +use serde::Deserialize; use crate::errors::ServiceError; use crate::models::{Pool, SlimUser, User}; diff --git a/simple-auth-server/src/invitation_handler.rs b/simple-auth-server/src/invitation_handler.rs index a076ea1c..c82521fe 100644 --- a/simple-auth-server/src/invitation_handler.rs +++ b/simple-auth-server/src/invitation_handler.rs @@ -1,5 +1,6 @@ use actix_web::{error::BlockingError, web, HttpResponse}; use diesel::{prelude::*, PgConnection}; +use serde::Deserialize; use crate::email_service::send_invitation; use crate::errors::ServiceError; diff --git a/simple-auth-server/src/main.rs b/simple-auth-server/src/main.rs index ddfbdfad..929ee2c5 100644 --- a/simple-auth-server/src/main.rs +++ b/simple-auth-server/src/main.rs @@ -1,7 +1,5 @@ #[macro_use] extern crate diesel; -#[macro_use] -extern crate serde_derive; use actix_identity::{CookieIdentityPolicy, IdentityService}; use actix_web::{middleware, web, App, HttpServer}; diff --git a/simple-auth-server/src/models.rs b/simple-auth-server/src/models.rs index 1f5d9695..6510b574 100644 --- a/simple-auth-server/src/models.rs +++ b/simple-auth-server/src/models.rs @@ -1,5 +1,6 @@ use super::schema::*; use diesel::{r2d2::ConnectionManager, PgConnection}; +use serde::{Deserialize, Serialize}; // type alias to use in multiple places pub type Pool = r2d2::Pool>; diff --git a/simple-auth-server/src/register_handler.rs b/simple-auth-server/src/register_handler.rs index 83a656f2..f8127245 100644 --- a/simple-auth-server/src/register_handler.rs +++ b/simple-auth-server/src/register_handler.rs @@ -1,5 +1,6 @@ use actix_web::{error::BlockingError, web, HttpResponse}; use diesel::prelude::*; +use serde::Deserialize; use crate::errors::ServiceError; use crate::models::{Invitation, Pool, SlimUser, User};