1
0
mirror of https://github.com/actix/examples synced 2024-11-23 14:31:07 +01:00

Bump tera version to 1.8.0, print the listening port to cli (#421)

Co-authored-by: ZhiFeng Hu <huzhifeng@coldlake.cn>
This commit is contained in:
netroby 2021-04-25 20:15:27 +08:00 committed by GitHub
parent fb897db380
commit ef13969220
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 86 additions and 34 deletions

117
Cargo.lock generated
View File

@ -203,7 +203,7 @@ dependencies = [
"mime", "mime",
"percent-encoding", "percent-encoding",
"pin-project 1.0.2", "pin-project 1.0.2",
"rand", "rand 0.7.3",
"regex", "regex",
"serde 1.0.117", "serde 1.0.117",
"serde_json", "serde_json",
@ -286,7 +286,7 @@ dependencies = [
"derive_more", "derive_more",
"futures-util", "futures-util",
"log", "log",
"rand", "rand 0.7.3",
"redis-async", "redis-async",
"serde 1.0.117", "serde 1.0.117",
"serde_json", "serde_json",
@ -1134,7 +1134,7 @@ dependencies = [
"mime", "mime",
"openssl", "openssl",
"percent-encoding", "percent-encoding",
"rand", "rand 0.7.3",
"rustls", "rustls",
"serde 1.0.117", "serde 1.0.117",
"serde_json", "serde_json",
@ -1169,7 +1169,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "721c249ab59cbc483ad4294c9ee2671835c1e43e9ffc277e6b4ecfef733cfdc5" checksum = "721c249ab59cbc483ad4294c9ee2671835c1e43e9ffc277e6b4ecfef733cfdc5"
dependencies = [ dependencies = [
"instant", "instant",
"rand", "rand 0.7.3",
] ]
[[package]] [[package]]
@ -1384,7 +1384,7 @@ dependencies = [
"hex", "hex",
"lazy_static", "lazy_static",
"linked-hash-map 0.5.3", "linked-hash-map 0.5.3",
"rand", "rand 0.7.3",
"serde 1.0.117", "serde 1.0.117",
"serde_json", "serde_json",
] ]
@ -1694,7 +1694,7 @@ dependencies = [
"hkdf", "hkdf",
"hmac 0.10.1", "hmac 0.10.1",
"percent-encoding", "percent-encoding",
"rand", "rand 0.7.3",
"sha2 0.9.2", "sha2 0.9.2",
"time 0.2.23", "time 0.2.23",
"version_check 0.9.2", "version_check 0.9.2",
@ -1707,7 +1707,7 @@ dependencies = [
"actix-identity", "actix-identity",
"actix-web", "actix-web",
"env_logger 0.8.2", "env_logger 0.8.2",
"rand", "rand 0.7.3",
] ]
[[package]] [[package]]
@ -2178,7 +2178,7 @@ dependencies = [
"actix-web", "actix-web",
"derive_more", "derive_more",
"env_logger 0.8.2", "env_logger 0.8.2",
"rand", "rand 0.7.3",
] ]
[[package]] [[package]]
@ -2477,6 +2477,17 @@ dependencies = [
"wasi 0.9.0+wasi-snapshot-preview1", "wasi 0.9.0+wasi-snapshot-preview1",
] ]
[[package]]
name = "getrandom"
version = "0.2.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c9495705279e7140bf035dde1f6e750c162df8b625267cd52cc44e0b156732c8"
dependencies = [
"cfg-if 1.0.0",
"libc",
"wasi 0.10.0+wasi-snapshot-preview1",
]
[[package]] [[package]]
name = "ghash" name = "ghash"
version = "0.3.0" version = "0.3.0"
@ -2507,9 +2518,9 @@ dependencies = [
[[package]] [[package]]
name = "globwalk" name = "globwalk"
version = "0.8.0" version = "0.8.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "178270263374052c40502e9f607134947de75302c1348d1a0e31db67c1691446" checksum = "93e3af942408868f6934a7b85134a3230832b9977cf66125df2f9edcfce4ddcc"
dependencies = [ dependencies = [
"bitflags", "bitflags",
"ignore", "ignore",
@ -3446,7 +3457,7 @@ dependencies = [
"lexical", "lexical",
"num-bigint", "num-bigint",
"num-traits 0.2.14", "num-traits 0.2.14",
"rand", "rand 0.7.3",
"regex", "regex",
"rust_decimal", "rust_decimal",
"serde 1.0.117", "serde 1.0.117",
@ -3805,7 +3816,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "17367f0cc86f2d25802b2c26ee58a7b23faeccf78a396094c13dced0d0182526" checksum = "17367f0cc86f2d25802b2c26ee58a7b23faeccf78a396094c13dced0d0182526"
dependencies = [ dependencies = [
"phf_shared", "phf_shared",
"rand", "rand 0.7.3",
] ]
[[package]] [[package]]
@ -3931,7 +3942,7 @@ dependencies = [
"hmac 0.9.0", "hmac 0.9.0",
"md5", "md5",
"memchr", "memchr",
"rand", "rand 0.7.3",
"sha2 0.9.2", "sha2 0.9.2",
"stringprep", "stringprep",
] ]
@ -4110,14 +4121,26 @@ version = "0.7.3"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6a6b1679d49b24bbfe0c803429aa1874472f50d9b363131f0e89fc356b544d03" checksum = "6a6b1679d49b24bbfe0c803429aa1874472f50d9b363131f0e89fc356b544d03"
dependencies = [ dependencies = [
"getrandom", "getrandom 0.1.15",
"libc", "libc",
"rand_chacha", "rand_chacha 0.2.2",
"rand_core", "rand_core 0.5.1",
"rand_hc", "rand_hc 0.2.0",
"rand_pcg", "rand_pcg",
] ]
[[package]]
name = "rand"
version = "0.8.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0ef9e7e66b4468674bfcb0c81af8b7fa0bb154fa9f28eb840da5c447baeb8d7e"
dependencies = [
"libc",
"rand_chacha 0.3.0",
"rand_core 0.6.2",
"rand_hc 0.3.0",
]
[[package]] [[package]]
name = "rand_chacha" name = "rand_chacha"
version = "0.2.2" version = "0.2.2"
@ -4125,7 +4148,17 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f4c8ed856279c9737206bf725bf36935d8666ead7aa69b52be55af369d193402" checksum = "f4c8ed856279c9737206bf725bf36935d8666ead7aa69b52be55af369d193402"
dependencies = [ dependencies = [
"ppv-lite86", "ppv-lite86",
"rand_core", "rand_core 0.5.1",
]
[[package]]
name = "rand_chacha"
version = "0.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e12735cf05c9e10bf21534da50a147b924d555dc7a547c42e6bb2d5b6017ae0d"
dependencies = [
"ppv-lite86",
"rand_core 0.6.2",
] ]
[[package]] [[package]]
@ -4134,7 +4167,16 @@ version = "0.5.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "90bde5296fc891b0cef12a6d03ddccc162ce7b2aff54160af9338f8d40df6d19" checksum = "90bde5296fc891b0cef12a6d03ddccc162ce7b2aff54160af9338f8d40df6d19"
dependencies = [ dependencies = [
"getrandom", "getrandom 0.1.15",
]
[[package]]
name = "rand_core"
version = "0.6.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "34cf66eb183df1c5876e2dcf6b13d57340741e8dc255b48e40a26de954d06ae7"
dependencies = [
"getrandom 0.2.2",
] ]
[[package]] [[package]]
@ -4143,7 +4185,16 @@ version = "0.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ca3129af7b92a17112d59ad498c6f81eaf463253766b90396d39ea7a39d6613c" checksum = "ca3129af7b92a17112d59ad498c6f81eaf463253766b90396d39ea7a39d6613c"
dependencies = [ dependencies = [
"rand_core", "rand_core 0.5.1",
]
[[package]]
name = "rand_hc"
version = "0.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3190ef7066a446f2e7f42e239d161e905420ccab01eb967c9eb27d21b2322a73"
dependencies = [
"rand_core 0.6.2",
] ]
[[package]] [[package]]
@ -4152,7 +4203,7 @@ version = "0.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "16abd0c1b639e9eb4d7c50c0b8100b0d0f849be2349829c740fe8e6eb4816429" checksum = "16abd0c1b639e9eb4d7c50c0b8100b0d0f849be2349829c740fe8e6eb4816429"
dependencies = [ dependencies = [
"rand_core", "rand_core 0.5.1",
] ]
[[package]] [[package]]
@ -4200,7 +4251,7 @@ dependencies = [
"actix-session", "actix-session",
"actix-web", "actix-web",
"env_logger 0.8.2", "env_logger 0.8.2",
"rand", "rand 0.7.3",
"serde 1.0.117", "serde 1.0.117",
"serde_json", "serde_json",
"time 0.2.23", "time 0.2.23",
@ -4229,7 +4280,7 @@ version = "0.3.5"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "de0737333e7a9502c789a36d7c7fa6092a49895d4faa31ca5df163857ded2e9d" checksum = "de0737333e7a9502c789a36d7c7fa6092a49895d4faa31ca5df163857ded2e9d"
dependencies = [ dependencies = [
"getrandom", "getrandom 0.1.15",
"redox_syscall", "redox_syscall",
"rust-argon2", "rust-argon2",
] ]
@ -5237,7 +5288,7 @@ checksum = "7a6e24d9338a0a5be79593e2fa15a648add6138caa803e2d5bc782c371732ca9"
dependencies = [ dependencies = [
"cfg-if 0.1.10", "cfg-if 0.1.10",
"libc", "libc",
"rand", "rand 0.7.3",
"redox_syscall", "redox_syscall",
"remove_dir_all", "remove_dir_all",
"winapi 0.3.9", "winapi 0.3.9",
@ -5307,9 +5358,9 @@ dependencies = [
[[package]] [[package]]
name = "tera" name = "tera"
version = "1.5.0" version = "1.8.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1381c83828bedd5ce4e59473110afa5381ffe523406d9ade4b77c9f7be70ff9a" checksum = "b64b021b8d3ab1f59ceae9e6cd1c26c8e7ce0322a9ebfff6c0e22b3b66938935"
dependencies = [ dependencies = [
"chrono", "chrono",
"chrono-tz", "chrono-tz",
@ -5319,7 +5370,7 @@ dependencies = [
"percent-encoding", "percent-encoding",
"pest", "pest",
"pest_derive", "pest_derive",
"rand", "rand 0.8.3",
"regex", "regex",
"serde 1.0.117", "serde 1.0.117",
"serde_json", "serde_json",
@ -5675,7 +5726,7 @@ dependencies = [
"idna", "idna",
"lazy_static", "lazy_static",
"log", "log",
"rand", "rand 0.7.3",
"smallvec", "smallvec",
"thiserror", "thiserror",
"tokio", "tokio",
@ -5725,7 +5776,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "04f8ab788026715fa63b31960869617cba39117e520eb415b0139543e325ab59" checksum = "04f8ab788026715fa63b31960869617cba39117e520eb415b0139543e325ab59"
dependencies = [ dependencies = [
"cfg-if 0.1.10", "cfg-if 0.1.10",
"rand", "rand 0.7.3",
"static_assertions 1.1.0", "static_assertions 1.1.0",
] ]
@ -5924,7 +5975,7 @@ version = "0.8.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9fde2f6a4bea1d6e007c4ad38c6839fa71cbb63b6dbf5b595aa38dc9b1093c11" checksum = "9fde2f6a4bea1d6e007c4ad38c6839fa71cbb63b6dbf5b595aa38dc9b1093c11"
dependencies = [ dependencies = [
"rand", "rand 0.7.3",
"serde 1.0.117", "serde 1.0.117",
] ]
@ -6274,7 +6325,7 @@ dependencies = [
"env_logger 0.8.2", "env_logger 0.8.2",
"futures", "futures",
"log", "log",
"rand", "rand 0.7.3",
] ]
[[package]] [[package]]
@ -6289,7 +6340,7 @@ dependencies = [
"bytes 0.5.6", "bytes 0.5.6",
"env_logger 0.8.2", "env_logger 0.8.2",
"futures", "futures",
"rand", "rand 0.7.3",
"serde 1.0.117", "serde 1.0.117",
"serde_json", "serde_json",
] ]
@ -6307,7 +6358,7 @@ dependencies = [
"bytes 0.5.6", "bytes 0.5.6",
"env_logger 0.8.2", "env_logger 0.8.2",
"futures", "futures",
"rand", "rand 0.7.3",
"serde 1.0.117", "serde 1.0.117",
"serde_json", "serde_json",
"tokio", "tokio",

View File

@ -6,6 +6,6 @@ edition = "2018"
[dependencies] [dependencies]
env_logger = "0.8" env_logger = "0.8"
tera = "1.0" tera = "1.8.0"
actix-http = "2" actix-http = "2"
actix-web = "3" actix-web = "3"

View File

@ -31,6 +31,7 @@ async fn main() -> std::io::Result<()> {
std::env::set_var("RUST_LOG", "actix_web=info"); std::env::set_var("RUST_LOG", "actix_web=info");
env_logger::init(); env_logger::init();
println!("Listening on: 127.0.0.1:8080, open browser and visit have a try!");
HttpServer::new(|| { HttpServer::new(|| {
let tera = let tera =
Tera::new(concat!(env!("CARGO_MANIFEST_DIR"), "/templates/**/*")).unwrap(); Tera::new(concat!(env!("CARGO_MANIFEST_DIR"), "/templates/**/*")).unwrap();