Merge branch 'feature/restful_api' into develop

This commit is contained in:
Kilerd Chan 2019-06-04 12:00:20 +08:00
commit 6756b1e147
28 changed files with 778 additions and 399 deletions

2
.gitignore vendored
View File

@ -6,4 +6,4 @@
**/*.rs.bk
.idea/
.env
.env

296
Cargo.lock generated
View File

@ -2,27 +2,28 @@
# It is not intended for manual editing.
[[package]]
name = "actix"
version = "0.8.1"
version = "0.8.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"actix-http 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)",
"actix-rt 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
"actix_derive 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
"bitflags 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)",
"bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)",
"crossbeam-channel 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)",
"derive_more 0.14.0 (registry+https://github.com/rust-lang/crates.io-index)",
"futures 0.1.26 (registry+https://github.com/rust-lang/crates.io-index)",
"hashbrown 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
"futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)",
"hashbrown 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)",
"lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
"log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)",
"parking_lot 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)",
"parking_lot 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)",
"smallvec 0.6.9 (registry+https://github.com/rust-lang/crates.io-index)",
"tokio-codec 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
"tokio-executor 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)",
"tokio-io 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)",
"tokio-tcp 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)",
"tokio-timer 0.2.10 (registry+https://github.com/rust-lang/crates.io-index)",
"trust-dns-resolver 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)",
"trust-dns-resolver 0.11.1 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
@ -31,7 +32,7 @@ version = "0.1.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)",
"futures 0.1.26 (registry+https://github.com/rust-lang/crates.io-index)",
"futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)",
"log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)",
"tokio-codec 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
"tokio-io 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)",
@ -39,33 +40,34 @@ dependencies = [
[[package]]
name = "actix-connect"
version = "0.1.5"
version = "0.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"actix-codec 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
"actix-service 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)",
"actix-utils 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)",
"actix-service 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
"actix-utils 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)",
"derive_more 0.14.0 (registry+https://github.com/rust-lang/crates.io-index)",
"either 1.5.2 (registry+https://github.com/rust-lang/crates.io-index)",
"futures 0.1.26 (registry+https://github.com/rust-lang/crates.io-index)",
"futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)",
"http 0.1.17 (registry+https://github.com/rust-lang/crates.io-index)",
"log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)",
"tokio-current-thread 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)",
"tokio-tcp 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)",
"trust-dns-resolver 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)",
"trust-dns-resolver 0.11.1 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "actix-files"
version = "0.1.0-betsa.1"
version = "0.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"actix-service 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)",
"actix-web 1.0.0-beta.2 (registry+https://github.com/rust-lang/crates.io-index)",
"actix-http 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)",
"actix-service 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
"actix-web 1.0.0-rc (registry+https://github.com/rust-lang/crates.io-index)",
"bitflags 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)",
"bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)",
"derive_more 0.14.0 (registry+https://github.com/rust-lang/crates.io-index)",
"futures 0.1.26 (registry+https://github.com/rust-lang/crates.io-index)",
"futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)",
"log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)",
"mime 0.3.13 (registry+https://github.com/rust-lang/crates.io-index)",
"mime_guess 2.0.0-alpha.6 (registry+https://github.com/rust-lang/crates.io-index)",
@ -75,15 +77,15 @@ dependencies = [
[[package]]
name = "actix-http"
version = "0.1.4"
version = "0.2.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"actix-codec 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
"actix-connect 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)",
"actix-connect 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
"actix-server-config 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
"actix-service 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)",
"actix-service 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
"actix-threadpool 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
"actix-utils 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)",
"actix-utils 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)",
"base64 0.10.1 (registry+https://github.com/rust-lang/crates.io-index)",
"bitflags 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)",
"brotli2 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)",
@ -96,9 +98,9 @@ dependencies = [
"encoding 0.2.33 (registry+https://github.com/rust-lang/crates.io-index)",
"failure 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)",
"flate2 1.0.7 (registry+https://github.com/rust-lang/crates.io-index)",
"futures 0.1.26 (registry+https://github.com/rust-lang/crates.io-index)",
"futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)",
"h2 0.1.18 (registry+https://github.com/rust-lang/crates.io-index)",
"hashbrown 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
"hashbrown 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)",
"http 0.1.17 (registry+https://github.com/rust-lang/crates.io-index)",
"httparse 1.3.3 (registry+https://github.com/rust-lang/crates.io-index)",
"indexmap 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)",
@ -119,12 +121,12 @@ dependencies = [
"tokio-current-thread 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)",
"tokio-tcp 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)",
"tokio-timer 0.2.10 (registry+https://github.com/rust-lang/crates.io-index)",
"trust-dns-resolver 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)",
"trust-dns-resolver 0.11.1 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "actix-router"
version = "0.1.3"
version = "0.1.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)",
@ -141,7 +143,7 @@ version = "0.2.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"actix-threadpool 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
"futures 0.1.26 (registry+https://github.com/rust-lang/crates.io-index)",
"futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)",
"tokio-current-thread 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)",
"tokio-executor 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)",
"tokio-reactor 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)",
@ -150,13 +152,13 @@ dependencies = [
[[package]]
name = "actix-server"
version = "0.4.3"
version = "0.5.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"actix-rt 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
"actix-server-config 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
"actix-service 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)",
"futures 0.1.26 (registry+https://github.com/rust-lang/crates.io-index)",
"actix-service 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
"futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)",
"log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)",
"mio 0.6.16 (registry+https://github.com/rust-lang/crates.io-index)",
"net2 0.2.33 (registry+https://github.com/rust-lang/crates.io-index)",
@ -174,18 +176,17 @@ name = "actix-server-config"
version = "0.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"futures 0.1.26 (registry+https://github.com/rust-lang/crates.io-index)",
"futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)",
"tokio-io 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)",
"tokio-tcp 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "actix-service"
version = "0.3.6"
version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"futures 0.1.26 (registry+https://github.com/rust-lang/crates.io-index)",
"void 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)",
"futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
@ -194,7 +195,7 @@ version = "0.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"derive_more 0.14.0 (registry+https://github.com/rust-lang/crates.io-index)",
"futures 0.1.26 (registry+https://github.com/rust-lang/crates.io-index)",
"futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)",
"lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
"log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)",
"num_cpus 1.10.0 (registry+https://github.com/rust-lang/crates.io-index)",
@ -204,13 +205,14 @@ dependencies = [
[[package]]
name = "actix-utils"
version = "0.3.5"
version = "0.4.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"actix-codec 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
"actix-service 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)",
"actix-service 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
"bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)",
"futures 0.1.26 (registry+https://github.com/rust-lang/crates.io-index)",
"either 1.5.2 (registry+https://github.com/rust-lang/crates.io-index)",
"futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)",
"log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)",
"tokio-current-thread 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)",
"tokio-timer 0.2.10 (registry+https://github.com/rust-lang/crates.io-index)",
@ -218,29 +220,29 @@ dependencies = [
[[package]]
name = "actix-web"
version = "1.0.0-beta.2"
version = "1.0.0-rc"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"actix-codec 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
"actix-http 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)",
"actix-router 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)",
"actix-http 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)",
"actix-router 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)",
"actix-rt 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
"actix-server 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)",
"actix-server 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)",
"actix-server-config 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
"actix-service 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)",
"actix-service 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
"actix-threadpool 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
"actix-utils 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)",
"actix-web-codegen 0.1.0-beta.1 (registry+https://github.com/rust-lang/crates.io-index)",
"awc 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
"actix-utils 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)",
"actix-web-codegen 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
"awc 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
"bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)",
"derive_more 0.14.0 (registry+https://github.com/rust-lang/crates.io-index)",
"encoding 0.2.33 (registry+https://github.com/rust-lang/crates.io-index)",
"futures 0.1.26 (registry+https://github.com/rust-lang/crates.io-index)",
"hashbrown 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
"futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)",
"hashbrown 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)",
"log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)",
"mime 0.3.13 (registry+https://github.com/rust-lang/crates.io-index)",
"net2 0.2.33 (registry+https://github.com/rust-lang/crates.io-index)",
"parking_lot 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)",
"parking_lot 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)",
"regex 1.1.6 (registry+https://github.com/rust-lang/crates.io-index)",
"serde 1.0.90 (registry+https://github.com/rust-lang/crates.io-index)",
"serde_json 1.0.39 (registry+https://github.com/rust-lang/crates.io-index)",
@ -251,11 +253,11 @@ dependencies = [
[[package]]
name = "actix-web-codegen"
version = "0.1.0-beta.1"
version = "0.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"quote 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)",
"syn 0.15.33 (registry+https://github.com/rust-lang/crates.io-index)",
"syn 0.15.34 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
@ -265,7 +267,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"proc-macro2 0.4.28 (registry+https://github.com/rust-lang/crates.io-index)",
"quote 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)",
"syn 0.15.33 (registry+https://github.com/rust-lang/crates.io-index)",
"syn 0.15.34 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
@ -316,16 +318,16 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "awc"
version = "0.1.1"
version = "0.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"actix-codec 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
"actix-http 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)",
"actix-service 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)",
"actix-http 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)",
"actix-service 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
"base64 0.10.1 (registry+https://github.com/rust-lang/crates.io-index)",
"bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)",
"derive_more 0.14.0 (registry+https://github.com/rust-lang/crates.io-index)",
"futures 0.1.26 (registry+https://github.com/rust-lang/crates.io-index)",
"futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)",
"log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)",
"mime 0.3.13 (registry+https://github.com/rust-lang/crates.io-index)",
"percent-encoding 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)",
@ -523,7 +525,7 @@ dependencies = [
"ident_case 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)",
"proc-macro2 0.4.28 (registry+https://github.com/rust-lang/crates.io-index)",
"quote 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)",
"syn 0.15.33 (registry+https://github.com/rust-lang/crates.io-index)",
"syn 0.15.34 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
@ -533,7 +535,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"darling_core 0.8.6 (registry+https://github.com/rust-lang/crates.io-index)",
"quote 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)",
"syn 0.15.33 (registry+https://github.com/rust-lang/crates.io-index)",
"syn 0.15.34 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
@ -545,7 +547,7 @@ dependencies = [
"derive_builder_core 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)",
"proc-macro2 0.4.28 (registry+https://github.com/rust-lang/crates.io-index)",
"quote 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)",
"syn 0.15.33 (registry+https://github.com/rust-lang/crates.io-index)",
"syn 0.15.34 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
@ -556,7 +558,7 @@ dependencies = [
"darling 0.8.6 (registry+https://github.com/rust-lang/crates.io-index)",
"proc-macro2 0.4.28 (registry+https://github.com/rust-lang/crates.io-index)",
"quote 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)",
"syn 0.15.33 (registry+https://github.com/rust-lang/crates.io-index)",
"syn 0.15.34 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
@ -567,7 +569,7 @@ dependencies = [
"proc-macro2 0.4.28 (registry+https://github.com/rust-lang/crates.io-index)",
"quote 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)",
"rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)",
"syn 0.15.33 (registry+https://github.com/rust-lang/crates.io-index)",
"syn 0.15.34 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
@ -595,7 +597,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"proc-macro2 0.4.28 (registry+https://github.com/rust-lang/crates.io-index)",
"quote 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)",
"syn 0.15.33 (registry+https://github.com/rust-lang/crates.io-index)",
"syn 0.15.34 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
@ -705,7 +707,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"proc-macro2 0.4.28 (registry+https://github.com/rust-lang/crates.io-index)",
"quote 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)",
"syn 0.15.33 (registry+https://github.com/rust-lang/crates.io-index)",
"syn 0.15.34 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
@ -720,14 +722,6 @@ dependencies = [
"termcolor 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "error-chain"
version = "0.8.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"backtrace 0.3.15 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "error-chain"
version = "0.12.0"
@ -752,7 +746,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"proc-macro2 0.4.28 (registry+https://github.com/rust-lang/crates.io-index)",
"quote 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)",
"syn 0.15.33 (registry+https://github.com/rust-lang/crates.io-index)",
"syn 0.15.34 (registry+https://github.com/rust-lang/crates.io-index)",
"synstructure 0.10.1 (registry+https://github.com/rust-lang/crates.io-index)",
]
@ -811,7 +805,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "futures"
version = "0.1.26"
version = "0.1.27"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
@ -840,7 +834,7 @@ dependencies = [
"byteorder 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)",
"bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)",
"fnv 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)",
"futures 0.1.26 (registry+https://github.com/rust-lang/crates.io-index)",
"futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)",
"http 0.1.17 (registry+https://github.com/rust-lang/crates.io-index)",
"indexmap 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)",
"log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)",
@ -851,7 +845,7 @@ dependencies = [
[[package]]
name = "hashbrown"
version = "0.2.2"
version = "0.3.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
@ -922,14 +916,13 @@ dependencies = [
[[package]]
name = "ipconfig"
version = "0.1.9"
version = "0.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"error-chain 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)",
"socket2 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)",
"widestring 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
"widestring 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
"winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)",
"winreg 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)",
"winreg 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
@ -937,6 +930,20 @@ name = "itoa"
version = "0.4.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "jsonwebtoken"
version = "6.0.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"base64 0.10.1 (registry+https://github.com/rust-lang/crates.io-index)",
"chrono 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)",
"ring 0.14.6 (registry+https://github.com/rust-lang/crates.io-index)",
"serde 1.0.90 (registry+https://github.com/rust-lang/crates.io-index)",
"serde_derive 1.0.90 (registry+https://github.com/rust-lang/crates.io-index)",
"serde_json 1.0.39 (registry+https://github.com/rust-lang/crates.io-index)",
"untrusted 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "kernel32-sys"
version = "0.2.2"
@ -980,6 +987,14 @@ dependencies = [
"scopeguard 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "lock_api"
version = "0.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"scopeguard 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "log"
version = "0.4.6"
@ -1207,6 +1222,16 @@ dependencies = [
"parking_lot_core 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "parking_lot"
version = "0.8.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"lock_api 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
"parking_lot_core 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)",
"rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "parking_lot_core"
version = "0.4.0"
@ -1219,6 +1244,21 @@ dependencies = [
"winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "parking_lot_core"
version = "0.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"cfg-if 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)",
"cloudabi 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.2.53 (registry+https://github.com/rust-lang/crates.io-index)",
"rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)",
"redox_syscall 0.1.54 (registry+https://github.com/rust-lang/crates.io-index)",
"rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)",
"smallvec 0.6.9 (registry+https://github.com/rust-lang/crates.io-index)",
"winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "percent-encoding"
version = "1.0.1"
@ -1250,7 +1290,7 @@ dependencies = [
"pest_meta 2.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
"proc-macro2 0.4.28 (registry+https://github.com/rust-lang/crates.io-index)",
"quote 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)",
"syn 0.15.33 (registry+https://github.com/rust-lang/crates.io-index)",
"syn 0.15.34 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
@ -1590,16 +1630,17 @@ dependencies = [
name = "rubble"
version = "0.3.1"
dependencies = [
"actix 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)",
"actix-files 0.1.0-betsa.1 (registry+https://github.com/rust-lang/crates.io-index)",
"actix-web 1.0.0-beta.2 (registry+https://github.com/rust-lang/crates.io-index)",
"actix 0.8.3 (registry+https://github.com/rust-lang/crates.io-index)",
"actix-files 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
"actix-web 1.0.0-rc (registry+https://github.com/rust-lang/crates.io-index)",
"chrono 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)",
"diesel 1.4.2 (registry+https://github.com/rust-lang/crates.io-index)",
"diesel_derives 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
"diesel_migrations 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
"dotenv 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)",
"futures 0.1.26 (registry+https://github.com/rust-lang/crates.io-index)",
"futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)",
"http 0.1.17 (registry+https://github.com/rust-lang/crates.io-index)",
"jsonwebtoken 6.0.1 (registry+https://github.com/rust-lang/crates.io-index)",
"lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
"log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)",
"openssl 0.10.22 (registry+https://github.com/rust-lang/crates.io-index)",
@ -1663,6 +1704,11 @@ name = "scopeguard"
version = "0.3.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "scopeguard"
version = "1.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "semver"
version = "0.9.0"
@ -1691,7 +1737,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"proc-macro2 0.4.28 (registry+https://github.com/rust-lang/crates.io-index)",
"quote 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)",
"syn 0.15.33 (registry+https://github.com/rust-lang/crates.io-index)",
"syn 0.15.34 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
@ -1809,7 +1855,7 @@ dependencies = [
[[package]]
name = "syn"
version = "0.15.33"
version = "0.15.34"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"proc-macro2 0.4.28 (registry+https://github.com/rust-lang/crates.io-index)",
@ -1832,7 +1878,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"proc-macro2 0.4.28 (registry+https://github.com/rust-lang/crates.io-index)",
"quote 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)",
"syn 0.15.33 (registry+https://github.com/rust-lang/crates.io-index)",
"syn 0.15.34 (registry+https://github.com/rust-lang/crates.io-index)",
"unicode-xid 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
]
@ -1907,7 +1953,7 @@ version = "0.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)",
"futures 0.1.26 (registry+https://github.com/rust-lang/crates.io-index)",
"futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)",
"tokio-io 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)",
]
@ -1916,7 +1962,7 @@ name = "tokio-current-thread"
version = "0.1.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"futures 0.1.26 (registry+https://github.com/rust-lang/crates.io-index)",
"futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)",
"tokio-executor 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)",
]
@ -1926,7 +1972,7 @@ version = "0.1.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"crossbeam-utils 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)",
"futures 0.1.26 (registry+https://github.com/rust-lang/crates.io-index)",
"futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
@ -1935,7 +1981,7 @@ version = "0.1.12"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)",
"futures 0.1.26 (registry+https://github.com/rust-lang/crates.io-index)",
"futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)",
"log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)",
]
@ -1945,7 +1991,7 @@ version = "0.1.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"crossbeam-utils 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)",
"futures 0.1.26 (registry+https://github.com/rust-lang/crates.io-index)",
"futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)",
"lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
"log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)",
"mio 0.6.16 (registry+https://github.com/rust-lang/crates.io-index)",
@ -1962,7 +2008,7 @@ name = "tokio-signal"
version = "0.2.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"futures 0.1.26 (registry+https://github.com/rust-lang/crates.io-index)",
"futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.2.53 (registry+https://github.com/rust-lang/crates.io-index)",
"mio 0.6.16 (registry+https://github.com/rust-lang/crates.io-index)",
"mio-uds 0.6.7 (registry+https://github.com/rust-lang/crates.io-index)",
@ -1979,7 +2025,7 @@ version = "0.1.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"fnv 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)",
"futures 0.1.26 (registry+https://github.com/rust-lang/crates.io-index)",
"futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
@ -1988,7 +2034,7 @@ version = "0.1.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)",
"futures 0.1.26 (registry+https://github.com/rust-lang/crates.io-index)",
"futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)",
"iovec 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
"mio 0.6.16 (registry+https://github.com/rust-lang/crates.io-index)",
"tokio-io 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)",
@ -2001,7 +2047,7 @@ version = "0.2.10"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"crossbeam-utils 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)",
"futures 0.1.26 (registry+https://github.com/rust-lang/crates.io-index)",
"futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)",
"slab 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)",
"tokio-executor 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)",
]
@ -2012,7 +2058,7 @@ version = "0.1.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)",
"futures 0.1.26 (registry+https://github.com/rust-lang/crates.io-index)",
"futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)",
"log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)",
"mio 0.6.16 (registry+https://github.com/rust-lang/crates.io-index)",
"tokio-codec 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
@ -2028,7 +2074,7 @@ dependencies = [
"byteorder 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)",
"enum-as-inner 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
"failure 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)",
"futures 0.1.26 (registry+https://github.com/rust-lang/crates.io-index)",
"futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)",
"idna 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)",
"lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
"log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)",
@ -2046,13 +2092,13 @@ dependencies = [
[[package]]
name = "trust-dns-resolver"
version = "0.11.0"
version = "0.11.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"cfg-if 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)",
"failure 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)",
"futures 0.1.26 (registry+https://github.com/rust-lang/crates.io-index)",
"ipconfig 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)",
"futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)",
"ipconfig 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
"lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
"log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)",
"lru-cache 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
@ -2201,7 +2247,7 @@ dependencies = [
"nom 4.2.3 (registry+https://github.com/rust-lang/crates.io-index)",
"proc-macro2 0.4.28 (registry+https://github.com/rust-lang/crates.io-index)",
"quote 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)",
"syn 0.15.33 (registry+https://github.com/rust-lang/crates.io-index)",
"syn 0.15.34 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
@ -2223,14 +2269,9 @@ name = "version_check"
version = "0.1.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "void"
version = "1.0.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "widestring"
version = "0.2.2"
version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
@ -2281,7 +2322,7 @@ dependencies = [
[[package]]
name = "winreg"
version = "0.5.1"
version = "0.6.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)",
@ -2305,20 +2346,20 @@ dependencies = [
]
[metadata]
"checksum actix 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)" = "409b193241782089260e5567aa8ac607a7607153613dbe8a15170ed3b29984fd"
"checksum actix 0.8.3 (registry+https://github.com/rust-lang/crates.io-index)" = "671ce3d27313f236827a5dd153a1073ad03ef31fc77f562020263e7830cf1ef7"
"checksum actix-codec 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "9f2c11af4b06dc935d8e1b1491dad56bfb32febc49096a91e773f8535c176453"
"checksum actix-connect 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "0dc9fb88787e5904e5030cae7d395f9908c2118ed655e48905f37febcad9a653"
"checksum actix-files 0.1.0-betsa.1 (registry+https://github.com/rust-lang/crates.io-index)" = "d2cd0e88f4009725e2a99d88653367d1175d27ba724ed7be23cb21d04f19ad97"
"checksum actix-http 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)" = "23f726f551edcf2ddfd9d56261aedede5337e5ed1eee17b66304b7c9f62458ca"
"checksum actix-router 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "e0d1617a8ae62ab7e053ac6849e6bc62a59ffd102e0218b7b84cadd87feed52e"
"checksum actix-connect 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d7fbab0d79b2f3415a79570e3db12eaa75c26239541e613b832655145a5e9488"
"checksum actix-files 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "63ed25d86e7916d156be3a9724bcf0129b01d19af7c0fb2145e5193061a92e57"
"checksum actix-http 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "0745c8573969a134a3d180a0d0e0342950d407d7e01600094a2bceff45335ac6"
"checksum actix-router 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "23224bb527e204261d0291102cb9b52713084def67d94f7874923baefe04ccf7"
"checksum actix-rt 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "ed0424cdf6542a43b32a8885c7c5099bf4110fad9b50d7fb220ab9c038ecf5ec"
"checksum actix-server 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)" = "39e2ead8e439b674917c1a1f10f1af5ba90eab903ee6164f5cde6d9504668696"
"checksum actix-server 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "ba8c936356c882420eab87051b12ca1926dc42348863d05fff7eb151df9cddbb"
"checksum actix-server-config 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "e78703f07d0bd08b426b482d53569d84f1e1929024f0431b3a5a2dc0c1c60e0f"
"checksum actix-service 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)" = "dcbfa034a61a48c128de169a019a5f9aa3ac2f7c63b18972e11b4c069321f36b"
"checksum actix-service 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d763880e39fce7ea702a636a4a275912e695547c5131c05a8de65f2c1e5f68f6"
"checksum actix-threadpool 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "97fa58548067c1f0a16a82cdb7c8823deac793d27efd17b51d6ea7861c6d3966"
"checksum actix-utils 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)" = "80b12b95a3550c49b8f75e80341608bceaa6c544b0c754a0a6ffcf89bdd6d723"
"checksum actix-web 1.0.0-beta.2 (registry+https://github.com/rust-lang/crates.io-index)" = "07bedc2058b6fb05ef5e600653141e51ea588b68f8e7a82358e098965deaae48"
"checksum actix-web-codegen 0.1.0-beta.1 (registry+https://github.com/rust-lang/crates.io-index)" = "b26f9ce2dff34bda98b3c5b3ec2467a8f1bf08c69b0ae8ff02bc7d74d6af9d84"
"checksum actix-utils 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)" = "7ab47adc5e67fc83a0c58570b40531f09814a5daa969e0d913ebeab908a43508"
"checksum actix-web 1.0.0-rc (registry+https://github.com/rust-lang/crates.io-index)" = "c364d8f025fa5b0849c093acc0a2de5eb7b00941cdfdfac11278f6b39ae3a279"
"checksum actix-web-codegen 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "f12fe2bc39a899594da6d67cfd6a1b6670b62e8af66b73f2fd4d1df6cb881699"
"checksum actix_derive 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "0bf5f6d7bf2d220ae8b4a7ae02a572bb35b7c4806b24049af905ab8110de156c"
"checksum adler32 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)" = "7e522997b529f05601e05166c07ed17789691f562762c7f3b987263d2dedee5c"
"checksum aho-corasick 0.6.10 (registry+https://github.com/rust-lang/crates.io-index)" = "81ce3d38065e618af2d7b77e10c5ad9a069859b4be3c2250f674af3840d9c8a5"
@ -2327,7 +2368,7 @@ dependencies = [
"checksum arc-swap 0.3.11 (registry+https://github.com/rust-lang/crates.io-index)" = "bc4662175ead9cd84451d5c35070517777949a2ed84551764129cedb88384841"
"checksum atty 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)" = "9a7d5b8723950951411ee34d271d99dddcc2035a16ab25310ea2c8cfd4369652"
"checksum autocfg 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "a6d640bee2da49f60a4068a7fae53acde8982514ab7bae8b8cea9e88cbcfd799"
"checksum awc 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "eeef7718dd236a395988abf75ecd749c6f22ec2a7e819310a3a5e3ae5ea990d9"
"checksum awc 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "5f4644ced3f67333ac73fd92db3206e0cef66b8880d0f6d1fbacab68f7c451ff"
"checksum backtrace 0.3.15 (registry+https://github.com/rust-lang/crates.io-index)" = "f106c02a3604afcdc0df5d36cc47b44b55917dbaf3d808f71c163a0ddba64637"
"checksum backtrace-sys 0.1.28 (registry+https://github.com/rust-lang/crates.io-index)" = "797c830ac25ccc92a7f8a7b9862bde440715531514594a6154e3d4a54dd769b6"
"checksum base64 0.10.1 (registry+https://github.com/rust-lang/crates.io-index)" = "0b25d992356d2eb0ed82172f5248873db5560c4721f564b13cb5193bda5e668e"
@ -2375,7 +2416,6 @@ dependencies = [
"checksum enum-as-inner 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "3d58266c97445680766be408285e798d3401c6d4c378ec5552e78737e681e37d"
"checksum env_logger 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)" = "b61fa891024a945da30a9581546e8cfaf5602c7b3f4c137a2805cf388f92075a"
"checksum error-chain 0.12.0 (registry+https://github.com/rust-lang/crates.io-index)" = "07e791d3be96241c77c43846b665ef1384606da2cd2a48730abe606a12906e02"
"checksum error-chain 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)" = "6930e04918388a9a2e41d518c25cf679ccafe26733fb4127dbf21993f2575d46"
"checksum failure 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "795bd83d3abeb9220f257e597aa0080a508b27533824adf336529648f6abf7e2"
"checksum failure_derive 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "ea1063915fd7ef4309e222a5a07cf9c319fb9c7836b1f89b85458672dbb127e1"
"checksum fake-simd 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "e88a8acf291dafb59c2d96e8f59828f3838bb1a70398823ade51a84de6a6deed"
@ -2386,12 +2426,12 @@ dependencies = [
"checksum fuchsia-cprng 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "a06f77d526c1a601b7c4cdd98f54b5eaabffc14d5f2f0296febdc7f357c6d3ba"
"checksum fuchsia-zircon 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "2e9763c69ebaae630ba35f74888db465e49e259ba1bc0eda7d06f4a067615d82"
"checksum fuchsia-zircon-sys 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "3dcaa9ae7725d12cdb85b3ad99a434db70b468c09ded17e012d86b5c1010f7a7"
"checksum futures 0.1.26 (registry+https://github.com/rust-lang/crates.io-index)" = "62941eff9507c8177d448bd83a44d9b9760856e184081d8cd79ba9f03dd24981"
"checksum futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)" = "a2037ec1c6c1c4f79557762eab1f7eae1f64f6cb418ace90fae88f0942b60139"
"checksum gcc 0.3.55 (registry+https://github.com/rust-lang/crates.io-index)" = "8f5f3913fa0bfe7ee1fd8248b6b9f42a5af4b9d65ec2dd2c3c26132b950ecfc2"
"checksum generic-array 0.12.0 (registry+https://github.com/rust-lang/crates.io-index)" = "3c0f28c2f5bfb5960175af447a2da7c18900693738343dc896ffbcabd9839592"
"checksum glob 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)" = "8be18de09a56b60ed0edf84bc9df007e30040691af7acd1c41874faac5895bfb"
"checksum h2 0.1.18 (registry+https://github.com/rust-lang/crates.io-index)" = "85ab6286db06040ddefb71641b50017c06874614001a134b423783e2db2920bd"
"checksum hashbrown 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "61e4900fa4e80b3d15c78a08ec8a08433246063fa7577e7b2c6426b3b21b1f79"
"checksum hashbrown 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "29fba9abe4742d586dfd0c06ae4f7e73a1c2d86b856933509b269d82cdf06e18"
"checksum hostname 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "21ceb46a83a85e824ef93669c8b390009623863b5c195d1ba747292c0c72f94e"
"checksum http 0.1.17 (registry+https://github.com/rust-lang/crates.io-index)" = "eed324f0f0daf6ec10c474f150505af2c143f251722bf9dbd1261bd1f2ee2c1a"
"checksum httparse 1.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "e8734b0cfd3bc3e101ec59100e101c2eecd19282202e87808b3037b442777a83"
@ -2401,8 +2441,9 @@ dependencies = [
"checksum idna 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "38f09e0f0b1fb55fdee1f17470ad800da77af5186a1a76c026b679358b7e844e"
"checksum indexmap 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7e81a7c05f79578dbc15793d8b619db9ba32b4577003ef3af1a91c416798c58d"
"checksum iovec 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "dbe6e417e7d0975db6512b90796e8ce223145ac4e33c377e4a42882a0e88bb08"
"checksum ipconfig 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)" = "08f7eadeaf4b52700de180d147c4805f199854600b36faa963d91114827b2ffc"
"checksum ipconfig 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "1b7b78ac2cfe6655f29ccc510ce0500c8356c3756dbce759d0ecb8a3718f2ef3"
"checksum itoa 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)" = "1306f3464951f30e30d12373d31c79fbd52d236e5e896fd92f96ec7babbbe60b"
"checksum jsonwebtoken 6.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "a81d1812d731546d2614737bee92aa071d37e9afa1409bc374da9e5e70e70b22"
"checksum kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7507624b29483431c0ba2d82aece8ca6cdba9382bff4ddd0f7490560c056098d"
"checksum language-tags 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "a91d884b6667cd606bb5a69aa0c99ba811a115fc68915e7056ec08a46e93199a"
"checksum lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "bc5729f27f159ddd61f4df6228e827e86643d4d3e7c32183cb30a1c08f604a14"
@ -2410,6 +2451,7 @@ dependencies = [
"checksum libc 0.2.53 (registry+https://github.com/rust-lang/crates.io-index)" = "ec350a9417dfd244dc9a6c4a71e13895a4db6b92f0b106f07ebbc3f3bc580cee"
"checksum linked-hash-map 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)" = "ae91b68aebc4ddb91978b11a1b02ddd8602a05ec19002801c5666000e05e0f83"
"checksum lock_api 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "62ebf1391f6acad60e5c8b43706dde4582df75c06698ab44511d15016bc2442c"
"checksum lock_api 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ed946d4529956a20f2d63ebe1b69996d5a2137c91913fe3ebbeff957f5bca7ff"
"checksum log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)" = "c84ec4b527950aa83a329754b01dbe3f58361d1c5efacd1f6d68c494d08a17c6"
"checksum lru-cache 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "31e24f1ad8321ca0e8a1e0ac13f23cb668e6f5466c2c57319f6a5cf1cc8e3b1c"
"checksum maplit 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "08cbb6b4fef96b6d77bfc40ec491b1690c779e77b05cd9f07f787ed376fd4c43"
@ -2436,7 +2478,9 @@ dependencies = [
"checksum openssl-sys 0.9.46 (registry+https://github.com/rust-lang/crates.io-index)" = "05636e06b4f8762d4b81d24a351f3966f38bd25ccbcfd235606c91fdb82cc60f"
"checksum owning_ref 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "49a4b8ea2179e6a2e27411d3bca09ca6dd630821cf6894c6c7c8467a8ee7ef13"
"checksum parking_lot 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)" = "ab41b4aed082705d1056416ae4468b6ea99d52599ecf3169b00088d43113e337"
"checksum parking_lot 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "fa7767817701cce701d5585b9c4db3cdd02086398322c1d7e8bf5094a96a2ce7"
"checksum parking_lot_core 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "94c8c7923936b28d546dfd14d4472eaf34c99b14e1c973a32b3e6d4eb04298c9"
"checksum parking_lot_core 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)" = "cb88cb1cb3790baa6776844f968fea3be44956cf184fa1be5a03341f5491278c"
"checksum percent-encoding 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "31010dd2e1ac33d5b46a5b413495239882813e0369f8ed8a5e266f173602f831"
"checksum pest 2.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "933085deae3f32071f135d799d75667b63c8dc1f4537159756e3d4ceab41868c"
"checksum pest_derive 2.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "833d1ae558dc601e9a60366421196a8d94bc0ac980476d0b67e1d0988d72b2d0"
@ -2485,6 +2529,7 @@ dependencies = [
"checksum ryu 0.2.7 (registry+https://github.com/rust-lang/crates.io-index)" = "eb9e9b8cde282a9fe6a42dd4681319bfb63f121b8a8ee9439c6f4107e58a46f7"
"checksum scheduled-thread-pool 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "1a2ff3fc5223829be817806c6441279c676e454cc7da608faf03b0ccc09d3889"
"checksum scopeguard 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "94258f53601af11e6a49f722422f6e3425c52b06245a5cf9bc09908b174f5e27"
"checksum scopeguard 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "b42e15e59b18a828bbf5c58ea01debb36b9b096346de35d941dcb89009f24a0d"
"checksum semver 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "1d7eb9ef2c18661902cc47e535f9bc51b78acd254da71d375c2f6720d9a40403"
"checksum semver-parser 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3"
"checksum serde 1.0.90 (registry+https://github.com/rust-lang/crates.io-index)" = "aa5f7c20820475babd2c077c3ab5f8c77a31c15e16ea38687b4c02d3e48680f4"
@ -2504,7 +2549,7 @@ dependencies = [
"checksum string 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "b639411d0b9c738748b5397d5ceba08e648f4f1992231aa859af1a017f31f60b"
"checksum string 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d0bbfb8937e38e34c3444ff00afb28b0811d9554f15c5ad64d12b0308d1d1995"
"checksum syn 0.11.11 (registry+https://github.com/rust-lang/crates.io-index)" = "d3b891b9015c88c576343b9b3e41c2c11a51c219ef067b264bd9c8aa9b441dad"
"checksum syn 0.15.33 (registry+https://github.com/rust-lang/crates.io-index)" = "ec52cd796e5f01d0067225a5392e70084acc4c0013fa71d55166d38a8b307836"
"checksum syn 0.15.34 (registry+https://github.com/rust-lang/crates.io-index)" = "a1393e4a97a19c01e900df2aec855a29f71cf02c402e2f443b8d2747c25c5dbe"
"checksum synom 0.11.3 (registry+https://github.com/rust-lang/crates.io-index)" = "a393066ed9010ebaed60b9eafa373d4b1baac186dd7e008555b0f702b51945b6"
"checksum synstructure 0.10.1 (registry+https://github.com/rust-lang/crates.io-index)" = "73687139bf99285483c96ac0add482c3776528beac1d97d444f6e91f203a2015"
"checksum tera 0.11.20 (registry+https://github.com/rust-lang/crates.io-index)" = "4b505279e19d8f7d24b1a9dc58327c9c36174b1a2c7ebdeac70792d017cb64f3"
@ -2524,7 +2569,7 @@ dependencies = [
"checksum tokio-timer 0.2.10 (registry+https://github.com/rust-lang/crates.io-index)" = "2910970404ba6fa78c5539126a9ae2045d62e3713041e447f695f41405a120c6"
"checksum tokio-udp 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "66268575b80f4a4a710ef83d087fdfeeabdce9b74c797535fbac18a2cb906e92"
"checksum trust-dns-proto 0.7.3 (registry+https://github.com/rust-lang/crates.io-index)" = "cc2f00e905d494cbca8a9e348d6e68c89847a370145244daf70bb2beb8dbc87f"
"checksum trust-dns-resolver 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)" = "cd731ac4ba8ad47020d46708a965a4703c44e4d944278e8835e8f7eafdc30aa2"
"checksum trust-dns-resolver 0.11.1 (registry+https://github.com/rust-lang/crates.io-index)" = "6c9992e58dba365798803c0b91018ff6c8d3fc77e06977c4539af2a6bfe0a039"
"checksum typenum 1.10.0 (registry+https://github.com/rust-lang/crates.io-index)" = "612d636f949607bdf9b123b4a6f6d966dedf3ff669f7f045890d3a4a73948169"
"checksum ucd-trie 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "71a9c5b1fe77426cf144cc30e49e955270f5086e31a6441dfa8b32efc09b9d77"
"checksum ucd-util 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "535c204ee4d8434478593480b8f86ab45ec9aae0e83c568ca81abf0fd0e88f86"
@ -2548,8 +2593,7 @@ dependencies = [
"checksum v_htmlescape 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)" = "7fbbe0fa88dd36f9c8cf61a218d4b953ba669de4d0785832f33cc72bd081e1be"
"checksum vcpkg 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)" = "def296d3eb3b12371b2c7d0e83bfe1403e4db2d7a0bba324a12b21c4ee13143d"
"checksum version_check 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "914b1a6776c4c929a602fafd8bc742e06365d4bcbe48c30f9cca5824f70dc9dd"
"checksum void 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "6a02e4885ed3bc0f2de90ea6dd45ebcbb66dacffe03547fadbb0eeae2770887d"
"checksum widestring 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7157704c2e12e3d2189c507b7482c52820a16dfa4465ba91add92f266667cadb"
"checksum widestring 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "effc0e4ff8085673ea7b9b2e3c73f6bd4d118810c9009ed8f1e16bd96c331db6"
"checksum winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)" = "167dc9d6949a9b857f3451275e911c3f44255842c1f7a76f33c55103a909087a"
"checksum winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)" = "f10e386af2b13e47c89e7236a7a14a086791a2b88ebad6df9bf42040195cf770"
"checksum winapi-build 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "2d315eee3b34aca4797b2da6b13ed88266e6d612562a0c46390af8299fc699bc"
@ -2557,6 +2601,6 @@ dependencies = [
"checksum winapi-util 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7168bab6e1daee33b4557efd0e95d5ca70a03706d39fa5f3fe7a236f584b03c9"
"checksum winapi-x86_64-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f"
"checksum wincolor 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "561ed901ae465d6185fa7864d63fbd5720d0ef718366c9a4dc83cf6170d7e9ba"
"checksum winreg 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "a27a759395c1195c4cc5cda607ef6f8f6498f64e78f7900f5de0a127a424704a"
"checksum winreg 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)" = "daf67b95d0b1bf421c4f11048d63110ca3719977169eec86396b614c8942b6e0"
"checksum winutil 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "7daf138b6b14196e3830a588acf1e86966c694d3e8fb026fb105b8b5dca07e6e"
"checksum ws2_32-sys 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "d59cefebd0c892fa2dd6de581e937301d8552cb44489cdff035c6187cb63fa5e"

View File

@ -7,27 +7,36 @@ license = "MIT"
edition = "2018"
[dependencies]
diesel = { version = "1.3.3", features = ["postgres", "r2d2", "chrono"] }
dotenv = "0.9.0"
r2d2 = "0.8"
lazy_static = "1.1"
openssl = "0.10.22"
# serde
serde = "1.0"
serde_derive = "1.0"
r2d2 = "0.8"
diesel = { version = "1.3.3", features = ["postgres", "r2d2", "chrono"] }
diesel_derives = "1.4.0"
diesel_migrations = "1.4.0"
tera = "0.11.0"
pulldown-cmark = { version = "0.1.2", default-features = false }
chrono = { version = "*", features = ["serde"] }
rust-crypto = "^0.2"
actix-web= "1.0.0-alpha.6"
actix-files = "0.1.0-alpha.6"
actix = "0.8.1"
diesel_migrations = "1.4.0"
futures = "0.1.26"
http = "0.1.17"
rand = "0.6.5"
pretty_env_logger = "0.3.0"
time = "0.1.42"
rss = "1.7.0"
diesel_derives = "1.4.0"
openssl = "0.10.22"
actix-web= "1.0.0-rc"
actix-files = "0.1.1"
futures = "0.1.26"
# log
log = "0.4.6"
pretty_env_logger = "0.3.0"
time = "0.1.42"
rand = "0.6.5"
rss = "1.7.0"
actix = "0.8.3"
jsonwebtoken = "6.0.1"

View File

@ -0,0 +1 @@
-- This file should undo anything in `up.sql`

View File

@ -0,0 +1,2 @@
-- Your SQL goes here
ALTER TABLE "public"."articles" ALTER COLUMN "publish_at" SET DEFAULT NOW();

View File

@ -1,3 +1,3 @@
#merge_imports = true
#normalize_comments = true
#reorder_impl_items = true
merge_imports = true
normalize_comments = true
reorder_impl_items = true

View File

@ -14,6 +14,7 @@ impl RubbleData {
let pool = self.pool.clone();
pool.get().unwrap()
}
pub fn render(&self, template_name: &str, data: &Context) -> String {
self.tera.render(template_name, data).unwrap()
}

View File

@ -5,22 +5,20 @@ extern crate diesel;
extern crate diesel_derives;
#[macro_use]
extern crate diesel_migrations;
#[macro_use]
extern crate log;
use actix_web::{
middleware::{
cors::Cors,
identity::{CookieIdentityPolicy, Identity, IdentityService},
Logger,
},
web, App, HttpServer,
middleware::{cors::Cors, Logger, NormalizePath},
App, HttpServer,
};
use dotenv::dotenv;
use crate::data::RubbleData;
use crate::pg_pool::database_pool_establish;
use crate::{data::RubbleData, pg_pool::database_pool_establish};
use actix_web::{
middleware::identity::{CookieIdentityPolicy, IdentityService},
web::{FormConfig, JsonConfig},
};
use lazy_static::lazy_static;
use std::sync::Arc;
use tera::compile_templates;
use time::Duration;
@ -30,68 +28,49 @@ mod models;
mod pg_pool;
mod routers;
mod schema;
mod view;
mod utils;
embed_migrations!();
lazy_static! {
static ref RANDOM_TOKEN_KEY: Vec<u8> = (0..32).map(|_| 0).collect();
}
fn main() {
dotenv().ok();
let sys = actix::System::new("rubble");
pretty_env_logger::init();
let database_url = std::env::var("DATABASE_URL").expect("database_url must be set");
let random_cookie_key: Vec<u8> = (0..32).map(|_| rand::random::<u8>()).collect();
let data = RubbleData {
pool: database_pool_establish(&database_url),
tera: Arc::new(compile_templates!("templates/**/*.html")),
};
embedded_migrations::run(&data.pool.get().expect("cannot get connection"));
embedded_migrations::run(&data.pool.get().expect("cannot get connection"))
.expect("panic on embedded database migration");
HttpServer::new(move || {
App::new()
.data(data.clone())
.data(JsonConfig::default().limit(256_000))
.data(FormConfig::default().limit(256_000))
.wrap(Logger::default())
.wrap(Cors::default())
.wrap(NormalizePath)
.wrap(IdentityService::new(
CookieIdentityPolicy::new(&random_cookie_key)
CookieIdentityPolicy::new(&RANDOM_TOKEN_KEY)
.name("auth-cookie")
.secure(false)
.max_age_time(Duration::days(3)),
))
.service(routers::article::homepage)
.service(routers::article::single_article)
.service(actix_files::Files::new(
"/statics",
"./templates/resources/",
))
.service(routers::admin::redirect_to_admin_panel)
.service(
web::scope("/admin/")
.service(routers::admin::admin_panel)
.service(routers::admin::admin_login)
.service(routers::admin::admin_authentication)
.service(routers::admin::article_creation)
.service(
web::resource("/article").route(
web::post()
.data(web::FormConfig::default().limit(256_000))
.to(routers::admin::article_save),
),
)
.service(routers::admin::article_edit)
.service(routers::admin::article_deletion)
.service(routers::admin::change_password)
.service(routers::admin::change_setting),
)
.service(routers::rss::rss_page)
.service(routers::article::get_article_by_url)
.service(routers::routes())
})
.bind(("0.0.0.0", 8000))
.unwrap()
.system_exit()
.start();
sys.run();
sys.run().expect("wrong on actix system run")
}

View File

@ -1,12 +1,8 @@
use crate::models::CRUD;
use crate::schema::articles;
use crate::{models::CRUD, schema::articles};
use chrono::NaiveDateTime;
use diesel::pg::PgConnection;
use diesel::prelude::*;
use diesel::result::Error;
use diesel::{pg::PgConnection, prelude::*, result::Error};
use diesel::query_builder::AsChangeset;
use diesel::{Insertable, Queryable};
use diesel::{query_builder::AsChangeset, Insertable, Queryable};
use serde::{Deserialize, Serialize};
#[derive(Queryable, Debug, Serialize)]
@ -20,52 +16,19 @@ pub struct Article {
pub url: Option<String>,
pub keywords: Vec<String>,
}
//
#[derive(Debug, Insertable, AsChangeset, Serialize, Deserialize)]
#[table_name = "articles"]
pub struct NewArticle {
pub id: Option<i32>,
pub title: String,
pub body: String,
pub published: bool,
pub user_id: i32,
pub publish_at: NaiveDateTime,
pub publish_at: Option<NaiveDateTime>,
pub url: Option<String>,
pub keywords: Vec<String>,
}
pub mod form {
use crate::models::article::NewArticle;
use chrono::NaiveDateTime;
use serde::{Deserialize, Serialize};
#[derive(Debug, Serialize, Deserialize)]
pub struct NewArticleForm {
pub id: Option<i32>,
pub title: String,
pub body: String,
pub published: bool,
pub user_id: i32,
pub publish_at: NaiveDateTime,
pub url: Option<String>,
pub keywords: String,
}
impl Into<NewArticle> for NewArticleForm {
fn into(self) -> NewArticle {
NewArticle {
id: self.id,
title: self.title,
body: self.body,
published: self.published,
user_id: self.user_id,
publish_at: self.publish_at,
url: self.url,
keywords: self.keywords.split(",").map(String::from).collect(),
}
}
}
}
impl Article {
pub fn link(&self) -> String {
match self.url {
@ -110,3 +73,70 @@ impl CRUD<NewArticle, NewArticle, i32> for Article {
articles::table.find(pk).first::<Article>(conn)
}
}
pub mod form {
use crate::models::article::NewArticle;
use chrono::NaiveDateTime;
use serde::{Deserialize, Serialize};
#[derive(Debug, Serialize, Deserialize)]
pub struct NewArticleFrom {
pub title: String,
pub body: String,
pub published: bool,
pub user_id: i32,
pub publish_at: Option<NaiveDateTime>,
pub url: Option<String>,
pub keywords: String,
}
impl From<NewArticleFrom> for NewArticle {
fn from(form: NewArticleFrom) -> Self {
Self {
title: form.title,
body: form.body,
published: form.published,
user_id: form.user_id,
publish_at: form.publish_at,
url: form.url,
keywords: if form.keywords.is_empty() {
vec![]
} else {
form.keywords.split(",").map(String::from).collect()
},
}
}
}
}
pub mod view {
use crate::models::article::Article;
use pulldown_cmark::{html, Parser};
use serde::Serialize;
#[derive(Debug, Serialize)]
pub struct ArticleView<'a> {
pub article: &'a Article,
pub timestamp: i64,
pub markdown_content: String,
pub description: String,
}
impl<'a> ArticleView<'a> {
pub fn from(article: &'a Article) -> ArticleView {
let content_split: Vec<_> = article.body.split("<!--more-->").collect();
let description_parser = Parser::new(&content_split[0]);
let parser = Parser::new(&article.body);
let mut description_buf = String::new();
let mut content_buf = String::new();
html::push_html(&mut content_buf, parser);
html::push_html(&mut description_buf, description_parser);
ArticleView {
article,
timestamp: article.publish_at.timestamp(),
markdown_content: content_buf,
description: description_buf,
}
}
}
}

View File

@ -1,10 +1,12 @@
use diesel::pg::{Pg, PgConnection};
use diesel::result::Error;
use diesel::{
pg::{Pg, PgConnection},
result::Error,
};
pub mod article;
pub mod setting;
pub mod token;
pub mod user;
pub trait CRUD<CreatedModel, UpdateModel, PK> {
fn create(conn: &PgConnection, from: &CreatedModel) -> Result<Self, Error>
where

View File

@ -1,9 +1,5 @@
use crate::models::CRUD;
use crate::schema::setting;
use diesel::pg::PgConnection;
use diesel::prelude::*;
use diesel::result::Error;
use diesel::{AsChangeset, Insertable, Queryable};
use crate::{models::CRUD, schema::setting};
use diesel::{pg::PgConnection, prelude::*, result::Error, AsChangeset, Insertable, Queryable};
use serde::{Deserialize, Serialize};
use std::collections::HashMap;
@ -21,8 +17,14 @@ pub struct SettingMap {
pub url: String,
pub analysis: String,
}
#[derive(Queryable, Debug, Serialize, Deserialize, AsChangeset)]
#[table_name = "setting"]
pub struct UpdateSetting {
pub value: Option<String>,
}
impl Setting {
// TODO refactor this method
pub fn load(conn: &PgConnection) -> SettingMap {
let settings = setting::table.load::<Setting>(conn).unwrap();
@ -51,7 +53,7 @@ impl Setting {
}
}
impl CRUD<(), Setting, String> for Setting {
impl CRUD<(), UpdateSetting, String> for Setting {
fn create(conn: &PgConnection, from: &()) -> Result<Self, Error> {
unimplemented!()
}
@ -60,7 +62,7 @@ impl CRUD<(), Setting, String> for Setting {
unimplemented!()
}
fn update(conn: &PgConnection, pk: String, value: &Setting) -> Result<Self, Error> {
fn update(conn: &PgConnection, pk: String, value: &UpdateSetting) -> Result<Self, Error> {
diesel::update(setting::table.find(&pk))
.set(value)
.get_result(conn)

6
src/models/token.rs Normal file
View File

@ -0,0 +1,6 @@
use serde::{Deserialize, Serialize};
#[derive(Serialize, Deserialize)]
pub struct Token {
pub token: String,
}

View File

@ -1,16 +1,18 @@
use crate::models::CRUD;
use chrono::NaiveDateTime;
use diesel::pg::PgConnection;
use diesel::result::Error;
use diesel::{pg::PgConnection, result::Error};
use crate::schema::users;
use crypto::digest::Digest;
use crypto::sha3::Sha3;
use crypto::{digest::Digest, sha3::Sha3};
use diesel::prelude::*;
use diesel::{AsChangeset, Insertable, Queryable};
use serde::Serialize;
use crate::{data::RubbleData, utils::jwt::JWTClaims};
use actix_web::{dev::Payload, error, FromRequest, HttpRequest};
use futures::IntoFuture;
#[derive(Queryable, Debug, Serialize, Insertable, AsChangeset)]
#[table_name = "users"]
pub struct User {
@ -65,3 +67,41 @@ impl CRUD<(), User, i32> for User {
users::table.filter(users::id.eq(pk)).first::<User>(conn)
}
}
impl FromRequest for User {
type Config = ();
type Error = actix_web::error::Error;
type Future = Result<Self, Self::Error>;
fn from_request(req: &HttpRequest, payload: &mut Payload) -> Self::Future {
let tokens: Vec<&str> = req
.headers()
.get("Authorization")
.ok_or(error::ErrorUnauthorized("cannot find authorization header"))?
.to_str()
.map_err(|_| error::ErrorBadRequest("error on deserialize token"))?
.splitn(2, ' ')
.collect();
let user_id = JWTClaims::decode(tokens[1].into())
.map_err(|_| error::ErrorUnauthorized("invalid jwt token"))?;
let data = req
.app_data::<RubbleData>()
.ok_or(error::ErrorBadGateway("error on get rubble data"))?;
let result = User::find_by_username(&data.postgres(), &user_id)
.map_err(|_| error::ErrorUnauthorized("error on get user"))?;
Ok(result)
}
}
pub mod input {
use serde::{Deserialize, Serialize};
#[derive(Deserialize, Serialize)]
pub struct LoginForm {
pub username: String,
pub password: String,
}
}

View File

@ -1,5 +1,4 @@
use diesel::pg::PgConnection;
use diesel::r2d2::ConnectionManager;
use diesel::{pg::PgConnection, r2d2::ConnectionManager};
use r2d2;
pub type ManagedPgConn = ConnectionManager<PgConnection>;

View File

@ -1,58 +1,50 @@
use actix_web::middleware::identity::Identity;
use actix_web::web::Form;
use actix_web::{get, post, web, Either, HttpResponse, Responder};
use actix_web::{
get,
middleware::identity::Identity,
post,
web::{self, Form},
Either, HttpResponse, Responder,
};
use chrono::{NaiveDateTime, Utc};
use serde::Deserialize;
use serde::{Deserialize, Serialize};
use tera::{Context, Tera};
use crate::data::RubbleData;
use crate::models::article::{Article, NewArticle};
use crate::models::setting::Setting;
use crate::models::user::User;
use crate::models::CRUD;
use crate::routers::RubbleResponder;
use crate::{
data::RubbleData,
models::{
article::{Article, NewArticle},
setting::{Setting, UpdateSetting},
token::Token,
user::User,
CRUD,
},
routers::RubbleResponder,
};
#[derive(Deserialize)]
use crate::utils::jwt::JWTClaims;
#[derive(Deserialize, Serialize)]
pub struct LoginForm {
pub username: String,
pub password: String,
}
#[derive(Deserialize)]
struct NewPassword {
pub struct NewPassword {
password: String,
}
#[get("/admin")]
#[get("")]
pub fn redirect_to_admin_panel() -> impl Responder {
RubbleResponder::Redirect("/admin/panel".into())
}
#[get("/panel")]
pub fn admin_panel(id: Identity, data: web::Data<RubbleData>) -> impl Responder {
if id.identity().is_none() {
return RubbleResponder::Redirect("/admin/login".into());
}
let articles = Article::read(&data.postgres());
let settings = Setting::load(&data.postgres());
let admin = User::find_by_username(&data.postgres(), &id.identity().unwrap())
.expect("cannot found this user");
let mut context = Context::new();
context.insert("setting", &settings);
context.insert("articles", &articles);
context.insert("admin", &admin);
RubbleResponder::Html(data.render("admin/panel.html", &context))
RubbleResponder::redirect("/admin/panel")
}
#[get("/login")]
pub fn admin_login(id: Identity, data: web::Data<RubbleData>) -> impl Responder {
match id.identity() {
Some(_) => RubbleResponder::Redirect("/admin/panel".into()),
None => RubbleResponder::Html(data.render("admin/login.html", &Context::new())),
if id.identity().is_some() {
RubbleResponder::redirect("/admin/panel")
} else {
RubbleResponder::html(data.render("admin/login.html", &Context::new()))
}
}
@ -68,22 +60,40 @@ pub fn admin_authentication(
Ok(login_user) => {
if login_user.authenticated(&user.password) {
id.remember(login_user.username);
info!("admin login");
RubbleResponder::Redirect("/admin/panel".into())
RubbleResponder::redirect("/admin/panel")
} else {
// TODO flash message or throw unauthorized
warn!("try logining admin with wrong password '{}'", user.password);
RubbleResponder::Redirect("/admin/login".into())
RubbleResponder::redirect("/admin/login")
}
}
Err(_) => RubbleResponder::Redirect("/admin/login".into()),
Err(_) => RubbleResponder::redirect("/admin/login"),
}
}
#[get("/panel")]
pub fn admin_panel(id: Identity, data: web::Data<RubbleData>) -> impl Responder {
if id.identity().is_none() {
return RubbleResponder::redirect("/admin/login");
}
let articles = Article::read(&data.postgres());
let settings = Setting::load(&data.postgres());
let admin = User::find_by_username(&data.postgres(), &id.identity().unwrap())
.expect("cannot found this user");
let mut context = Context::new();
context.insert("setting", &settings);
context.insert("articles", &articles);
context.insert("admin", &admin);
RubbleResponder::html(data.render("admin/panel.html", &context))
}
#[get("/article/new")]
pub fn article_creation(id: Identity, data: web::Data<RubbleData>) -> impl Responder {
if id.identity().is_none() {
return RubbleResponder::Redirect("/admin/login".into());
return RubbleResponder::redirect("/admin/login");
}
let admin = User::find_by_username(&data.postgres(), &id.identity().unwrap())
@ -92,18 +102,18 @@ pub fn article_creation(id: Identity, data: web::Data<RubbleData>) -> impl Respo
let mut context = Context::new();
let article = NewArticle {
id: None,
title: String::new(),
body: String::new(),
published: true,
user_id: admin.id,
publish_at: NaiveDateTime::from_timestamp(Utc::now().timestamp(), 0),
publish_at: Some(NaiveDateTime::from_timestamp(Utc::now().timestamp(), 0)),
url: None,
keywords: vec![],
};
context.insert("article", &article);
RubbleResponder::Html(data.render("admin/article_add.html", &context))
RubbleResponder::html(data.render("admin/article_add.html", &context))
}
#[get("/article/{article_id}")]
@ -113,7 +123,7 @@ pub fn article_edit(
data: web::Data<RubbleData>,
) -> impl Responder {
if id.identity().is_none() {
return RubbleResponder::Redirect("/admin/login".into());
return RubbleResponder::redirect("/admin/login");
}
let admin = User::find_by_username(&data.postgres(), &id.identity().unwrap())
@ -125,37 +135,47 @@ pub fn article_edit(
Ok(article) => {
let mut context = Context::new();
context.insert("article", &article);
RubbleResponder::Html(data.render("admin/article_add.html", &context))
RubbleResponder::html(data.render("admin/article_add.html", &context))
}
Err(_) => RubbleResponder::Redirect("/admin/panel".into()),
Err(_) => RubbleResponder::redirect("/admin/panel"),
}
}
#[post("/article")]
pub fn article_save(
id: Identity,
article: Form<crate::models::article::form::NewArticleForm>,
article: Form<crate::models::article::form::NewArticleFrom>,
data: web::Data<RubbleData>,
) -> impl Responder {
if id.identity().is_none() {
return RubbleResponder::Redirect("/admin/login".into());
return RubbleResponder::redirect("/admin/login");
}
let article_title = article.title.clone();
let admin = User::find_by_username(&data.postgres(), &id.identity().unwrap())
.expect("cannot found this user");
let res = if let Some(article_id) = article.id {
info!("updating article #{} {}", article_id, article_title);
Article::update(&data.postgres(), article_id, &article.into_inner().into())
} else {
info!("creating new article {}", article_title);
Article::create(&data.postgres(), &article.into_inner().into())
};
Article::create(&data.postgres(), &article.into_inner().into());
if res.is_err() {
error!("error on updating/creating article {}", article_title);
RubbleResponder::redirect("/admin/panel")
}
#[post("/article/{aid}")]
pub fn article_update(
id: Identity,
aid: web::Path<i32>,
article: Form<crate::models::article::form::NewArticleFrom>,
data: web::Data<RubbleData>,
) -> impl Responder {
if id.identity().is_none() {
return RubbleResponder::redirect("/admin/login");
}
RubbleResponder::Redirect("/admin/panel".into())
let admin = User::find_by_username(&data.postgres(), &id.identity().unwrap())
.expect("cannot found this user");
Article::update(&data.postgres(), *aid, &article.into_inner().into());
RubbleResponder::redirect("/admin/panel")
}
#[post("/article/delete/{article_id}")]
@ -165,7 +185,7 @@ pub fn article_deletion(
data: web::Data<RubbleData>,
) -> impl Responder {
if id.identity().is_none() {
return RubbleResponder::Redirect("/admin/login".into());
return RubbleResponder::redirect("/admin/login");
}
let admin = User::find_by_username(&data.postgres(), &id.identity().unwrap())
@ -173,8 +193,8 @@ pub fn article_deletion(
let i = article_id.into_inner();
Article::delete(&data.postgres(), i);
info!("deleting article {}", i);
RubbleResponder::Redirect("/admin/panel".into())
RubbleResponder::redirect("/admin/panel")
}
#[post("/password")]
@ -184,7 +204,7 @@ pub fn change_password(
data: web::Data<RubbleData>,
) -> impl Responder {
if id.identity().is_none() {
return RubbleResponder::Redirect("/admin/login".into());
return RubbleResponder::redirect("/admin/login");
}
let mut admin = User::find_by_username(&data.postgres(), &id.identity().unwrap())
@ -192,8 +212,7 @@ pub fn change_password(
admin.password = User::password_generate(&password.password).to_string();
User::update(&data.postgres(), admin.id, &admin);
id.forget();
info!("updating password");
RubbleResponder::Redirect("/admin/panel".into())
RubbleResponder::redirect("/admin/panel")
}
#[post("/setting")]
@ -203,15 +222,17 @@ pub fn change_setting(
data: web::Data<RubbleData>,
) -> impl Responder {
if id.identity().is_none() {
return RubbleResponder::Redirect("/admin/login".into());
return RubbleResponder::redirect("/admin/login");
}
let mut admin = User::find_by_username(&data.postgres(), &id.identity().unwrap())
.expect("cannot found this user");
Setting::update(&data.postgres(), setting.name.clone(), &setting);
info!("updating setting {:?} to {:?}", setting.name, setting.value);
RubbleResponder::Redirect("/admin/panel".into())
let update_setting = UpdateSetting {
value: setting.value.clone(),
};
Setting::update(&data.postgres(), setting.name.clone(), &update_setting);
RubbleResponder::redirect("/admin/panel")
}
#[cfg(test)]

View File

@ -0,0 +1,56 @@
use crate::{
data::RubbleData,
models::{article::Article, user::User, CRUD},
routers::RubbleResponder,
};
use actix_web::{delete, get, post, put, web, Responder};
#[get("")]
pub fn get_all_article(user: User, data: web::Data<RubbleData>) -> impl Responder {
RubbleResponder::json(Article::read(&data.postgres()))
}
#[get("/{id}")]
pub fn get_all_article_by_id(
user: User,
id: web::Path<i32>,
data: web::Data<RubbleData>,
) -> impl Responder {
Article::get_by_pk(&data.postgres(), *id)
.map(|data| RubbleResponder::json(data))
.map_err(|_| RubbleResponder::not_found())
}
#[post("")]
pub fn crate_article(
user: User,
article: web::Json<crate::models::article::NewArticle>,
data: web::Data<RubbleData>,
) -> impl Responder {
Article::create(&data.postgres(), &article)
.map(RubbleResponder::json)
.map_err(|_| RubbleResponder::bad_request("something wrong when creating article"))
}
#[put("/{id}")]
pub fn update_article_by_id(
user: User,
id: web::Path<i32>,
article: web::Json<crate::models::article::NewArticle>,
data: web::Data<RubbleData>,
) -> impl Responder {
Article::update(&data.postgres(), *id, &article)
.map(|data| RubbleResponder::json(data))
.map_err(|_| RubbleResponder::bad_request("something wrong when updating article"))
}
#[delete("/{id}")]
pub fn delete_article_by_id(
user: User,
id: web::Path<i32>,
data: web::Data<RubbleData>,
) -> impl Responder {
Article::delete(&data.postgres(), *id)
.map(|_| RubbleResponder::json("Ok"))
.map_err(|_| RubbleResponder::bad_request("something wrong when deleting article"))
}

3
src/routers/api/mod.rs Normal file
View File

@ -0,0 +1,3 @@
pub mod article;
pub mod setting;
pub mod user;

View File

@ -0,0 +1,28 @@
use crate::{
data::RubbleData,
models::{
setting::{Setting, UpdateSetting},
user::User,
CRUD,
},
routers::RubbleResponder,
};
use actix_web::{delete, get, post, put, web, Responder};
#[get("")]
pub fn get_settings(user: User, data: web::Data<RubbleData>) -> impl Responder {
RubbleResponder::json(Setting::load(&data.postgres()))
}
#[put("/{key}")]
pub fn update_setting_by_key(
user: User,
key: web::Path<String>,
value: web::Json<UpdateSetting>,
data: web::Data<RubbleData>,
) -> impl Responder {
let string = (*key).clone();
Setting::update(&data.postgres(), string, &value)
.map(RubbleResponder::json)
.map_err(|_| RubbleResponder::bad_request("error on updating setting"))
}

58
src/routers/api/user.rs Normal file
View File

@ -0,0 +1,58 @@
//! /authentications routes
use crate::{
data::RubbleData,
models::{
token::Token,
user::{input::LoginForm, User},
},
routers::RubbleResponder,
utils::jwt::JWTClaims,
};
use actix_web::{delete, get, post, put, web, Responder};
#[post("/token")]
pub fn admin_authentication(
user: web::Json<LoginForm>,
data: web::Data<RubbleData>,
) -> impl Responder {
let fetched_user = User::find_by_username(&data.postgres(), &user.username);
match fetched_user {
Ok(login_user) => {
if login_user.authenticated(&user.password) {
let string = JWTClaims::encode(&login_user);
RubbleResponder::json(Token { token: string })
} else {
RubbleResponder::unauthorized("invalid password")
}
}
Err(_) => RubbleResponder::unauthorized("invalid username"),
}
}
#[get("")]
pub fn get_all_users() -> impl Responder {
unreachable!()
}
#[post("")]
pub fn crate_user() -> impl Responder {
unreachable!()
}
#[put("/{id}")]
pub fn update_user_by_id() -> impl Responder {
unreachable!()
}
#[delete("/{id}")]
pub fn delete_user_by_id() -> impl Responder {
unreachable!()
}
#[put("/{id}/password")]
pub fn update_user_password() -> impl Responder {
unreachable!()
}

View File

@ -1,15 +1,18 @@
use crate::data::RubbleData;
use crate::models::article::Article;
use crate::models::setting::Setting;
use crate::models::CRUD;
use crate::pg_pool::Pool;
use crate::routers::RubbleResponder;
use crate::view::article::ArticleView;
use crate::{
data::RubbleData,
models::{
article::{view::ArticleView, Article},
setting::Setting,
CRUD,
},
pg_pool::Pool,
routers::RubbleResponder,
};
use actix_web::{get, web, Either, HttpResponse, Responder};
use std::sync::Arc;
use std::{result::Result, sync::Arc};
use tera::{Context, Tera};
#[get("/")]
#[get("")]
pub fn homepage(data: web::Data<RubbleData>) -> impl Responder {
let vec: Vec<Article> = Article::read(&data.postgres());
let article_view: Vec<_> = vec
@ -24,21 +27,21 @@ pub fn homepage(data: web::Data<RubbleData>) -> impl Responder {
context.insert("setting", &settings);
context.insert("articles", &article_view);
RubbleResponder::Html(data.render("homepage.html", &context))
RubbleResponder::html(data.render("homepage.html", &context))
}
#[get("/archives/{archives_id}")]
#[get("archives/{archives_id}")]
pub fn single_article(archives_id: web::Path<i32>, data: web::Data<RubbleData>) -> impl Responder {
let article = Article::get_by_pk(&data.postgres(), archives_id.into_inner());
if let Err(e) = article {
return RubbleResponder::NotFound;
return RubbleResponder::not_found();
}
let article1 = article.unwrap();
if let Some(ref to) = article1.url {
if to.len() != 0 {
return RubbleResponder::Redirect(format!("/{}", to));
return RubbleResponder::redirect(format!("/{}", to));
}
}
@ -50,15 +53,15 @@ pub fn single_article(archives_id: web::Path<i32>, data: web::Data<RubbleData>)
context.insert("setting", &settings);
context.insert("article", &view);
RubbleResponder::Html(data.render("archives.html", &context))
RubbleResponder::html(data.render("archives.html", &context))
}
#[get("/{url}")]
#[get("{url}")]
pub fn get_article_by_url(url: web::Path<String>, data: web::Data<RubbleData>) -> impl Responder {
let article = Article::find_by_url(&data.postgres(), &url.into_inner());
if let Err(e) = article {
return RubbleResponder::NotFound;
return RubbleResponder::not_found();
}
let article1 = article.unwrap();
@ -70,5 +73,5 @@ pub fn get_article_by_url(url: web::Path<String>, data: web::Data<RubbleData>) -
context.insert("setting", &settings);
context.insert("article", &view);
RubbleResponder::Html(data.render("archives.html", &context))
RubbleResponder::html(data.render("archives.html", &context))
}

View File

@ -1,35 +1,114 @@
use actix_web::{HttpRequest, HttpResponse, Responder};
pub mod admin;
pub mod article;
use actix_web::error::Error;
use actix_web::{error::Error, web, Scope};
use futures::future::{err, ok, FutureResult};
use serde::{de::DeserializeOwned, Deserialize, Serialize};
pub mod admin;
pub mod api;
pub mod article;
pub mod rss;
pub enum RubbleResponder {
Html(String),
Redirect(String),
NotFound,
RedirectPermanently(String),
#[derive(Deserialize, Serialize)]
pub struct JsonResponse<T> {
data: T,
}
impl Responder for RubbleResponder {
type Error = Error;
type Future = FutureResult<HttpResponse, Error>;
#[derive(Deserialize, Serialize)]
pub struct ErrorResponse<T> {
message: T,
}
fn respond_to(self, req: &HttpRequest) -> Self::Future {
match self {
RubbleResponder::Html(content) => ok(HttpResponse::Ok()
.content_type("text/html; charset=utf-8")
.body(content)),
RubbleResponder::Redirect(to) => ok(HttpResponse::Found()
.header(http::header::LOCATION, to)
.finish()),
RubbleResponder::NotFound => ok(HttpResponse::NotFound().finish()),
RubbleResponder::RedirectPermanently(to) => ok(HttpResponse::MovedPermanently()
.header(http::header::LOCATION, to)
.finish()),
}
pub struct RubbleResponder;
impl RubbleResponder {
pub fn html(content: impl Into<String>) -> HttpResponse {
HttpResponse::Ok()
.content_type("text/html; charset=utf-8")
.body(content.into())
}
pub fn json(data: impl Serialize) -> HttpResponse {
HttpResponse::Ok()
.header(
http::header::CONTENT_TYPE,
"application/json; charset=utf-8",
)
.json(JsonResponse { data })
}
pub fn text(content: impl Into<String>) -> HttpResponse {
HttpResponse::Ok().body(content.into())
}
pub fn redirect(to: impl Into<String>) -> HttpResponse {
HttpResponse::Found()
.header(http::header::LOCATION, to.into())
.finish()
}
pub fn redirect_permanently(to: impl Into<String>) -> HttpResponse {
HttpResponse::MovedPermanently()
.header(http::header::LOCATION, to.into())
.finish()
}
pub fn not_found() -> HttpResponse {
HttpResponse::NotFound().finish()
}
pub fn unauthorized(reason: impl Serialize) -> HttpResponse {
HttpResponse::Unauthorized().json(&ErrorResponse { message: reason })
}
pub fn bad_gateway(reason: impl Serialize) -> HttpResponse {
HttpResponse::BadGateway().json(&ErrorResponse { message: reason })
}
pub fn bad_request(reason: impl Serialize) -> HttpResponse {
HttpResponse::BadRequest().json(&ErrorResponse { message: reason })
}
}
pub fn routes() -> Scope {
web::scope("/")
.service(
web::scope("/api")
.service(web::scope("/users").service(api::user::admin_authentication))
.service(
web::scope("/articles")
.service(api::article::get_all_article)
.service(api::article::get_all_article_by_id)
.service(api::article::crate_article)
.service(api::article::update_article_by_id)
.service(api::article::delete_article_by_id),
)
.service(
web::scope("/settings")
.service(api::setting::get_settings)
.service(api::setting::update_setting_by_key),
),
)
.service(
web::scope("/admin")
.service(admin::redirect_to_admin_panel)
.service(admin::admin_login)
.service(admin::admin_authentication)
.service(admin::admin_panel)
.service(admin::article_creation)
.service(admin::article_deletion)
.service(admin::article_edit)
.service(admin::article_save)
.service(admin::article_update)
.service(admin::change_password)
.service(admin::change_setting),
)
.service(article::homepage)
.service(article::single_article)
.service(actix_files::Files::new(
"/statics",
"./templates/resources/",
))
.service(rss::rss_)
.service(article::get_article_by_url)
}

View File

@ -1,18 +1,24 @@
use crate::data::RubbleData;
use crate::models::{article::Article, setting::Setting, CRUD};
use crate::pg_pool::Pool;
use crate::view::article::ArticleView;
use crate::{
data::RubbleData,
models::{
article::{view::ArticleView, Article},
setting::Setting,
CRUD,
},
pg_pool::Pool,
};
use actix_web::{get, web, HttpResponse, Responder};
use rss::{Channel, ChannelBuilder, Item, ItemBuilder};
use std::collections::HashMap;
#[get("/rss")]
pub fn rss_page(data: web::Data<RubbleData>) -> impl Responder {
pub fn rss_(data: web::Data<RubbleData>) -> impl Responder {
let articles = Article::read(&data.postgres());
let setting = Setting::load(&data.postgres());
let items: Vec<Item> = articles
.iter()
.filter(|article| article.published == true)
.map(ArticleView::from)
.map(|item| {
ItemBuilder::default()

41
src/utils/jwt.rs Normal file
View File

@ -0,0 +1,41 @@
use crate::{models::user::User, RANDOM_TOKEN_KEY};
use chrono::prelude::*;
use jsonwebtoken::{decode as jwt_decode, encode as jwt_encode, Algorithm, Header, Validation};
use serde::{Deserialize, Serialize};
use std::ops::Add;
use time::Duration;
#[derive(Debug, Serialize, Deserialize)]
pub struct JWTClaims {
iat: usize,
sub: String,
exp: usize,
id: i32,
username: String,
}
impl JWTClaims {
pub fn encode(user: &User) -> String {
let now: DateTime<Utc> = Utc::now();
let expire: DateTime<Utc> = Utc::now().add(Duration::days(7));
let claims = JWTClaims {
iat: now.timestamp() as usize,
sub: String::from("LOGIN_TOKEN"),
exp: expire.timestamp() as usize,
id: user.id,
username: user.username.clone(),
};
jwt_encode(&Header::default(), &claims, &RANDOM_TOKEN_KEY).unwrap()
}
pub fn decode(token: String) -> Result<String, ()> {
let claims = jwt_decode::<JWTClaims>(
token.as_str(),
&RANDOM_TOKEN_KEY,
&Validation::new(Algorithm::HS256),
)
.map_err(|_| ())?;
Ok(claims.claims.username)
}
}

1
src/utils/mod.rs Normal file
View File

@ -0,0 +1 @@
pub mod jwt;

View File

@ -1,30 +0,0 @@
use crate::models::article::Article;
use pulldown_cmark::html;
use pulldown_cmark::Parser;
use serde::Serialize;
#[derive(Debug, Serialize)]
pub struct ArticleView<'a> {
pub article: &'a Article,
pub timestamp: i64,
pub markdown_content: String,
pub description: String,
}
impl<'a> ArticleView<'a> {
pub fn from(article: &'a Article) -> ArticleView {
let content_split: Vec<_> = article.body.split("<!--more-->").collect();
let description_parser = Parser::new(&content_split[0]);
let parser = Parser::new(&article.body);
let mut description_buf = String::new();
let mut content_buf = String::new();
html::push_html(&mut content_buf, parser);
html::push_html(&mut description_buf, description_parser);
ArticleView {
article,
timestamp: article.publish_at.timestamp(),
markdown_content: content_buf,
description: description_buf,
}
}
}

View File

@ -1 +0,0 @@
pub mod article;

View File

@ -9,9 +9,8 @@
</head>
<body>
<form action="/admin/article" method="post">
<form action='/admin/article{% if article.id %}/{{ article.id }}{% endif %}' method="post">
{% if article.id %}<input type="hidden" name="id" value="{{ article.id }}">{% endif %}
<div>
Title:
<input type="text" name="title" placeholder="title" required value="{{ article.title }}">
@ -27,7 +26,7 @@
</div>
<div>
PUBLISH_AT:
<input type="datetime-local" name="publish_at" id="publish_at" value="{{ article.publish_at }}">
<input type="datetime-local" name="publish_at" id="publish_at" value="{{ article.publish_at }}" required>
</div>
<div>
PUBLISHED:

View File

@ -88,13 +88,13 @@
<form action="/admin/setting" method="post">
Site Title:
<input type="hidden" name="name" value="title" required>
<input type="text" name="value" placeholder="value" value="{{ setting.title }}" required>
<input type="text" name="value" placeholder="value" value="{{ setting.title }}">
<button>change</button>
</form>
<form action="/admin/setting" method="post">
Description:
<input type="hidden" name="name" value="description" required>
<input type="text" name="value" placeholder="value" value="{{ setting.description }}" required>
<input type="text" name="value" placeholder="value" value="{{ setting.description }}">
<button>change</button>
</form>
<form action="/admin/setting" method="post">
@ -106,7 +106,7 @@
<form action="/admin/setting" method="post">
Analysis:
<input type="hidden" name="name" value="analysis" required>
<input type="text" name="value" placeholder="value" value="{{ setting.analysis }}" required>
<input type="text" name="value" placeholder="value" value="{{ setting.analysis }}">
<button>change</button>
</form>
</section>