using custom version of actix-codegen and cors for pow routes

This commit is contained in:
realaravinth 2021-05-25 14:34:24 +05:30
parent 0421cb681c
commit 72667bd2e1
No known key found for this signature in database
GPG key ID: AD9F0F08E855ED88
26 changed files with 334 additions and 363 deletions

297
Cargo.lock generated
View file

@ -113,7 +113,7 @@ dependencies = [
"pin-project 1.0.7",
"rand 0.7.3",
"regex",
"serde 1.0.125",
"serde 1.0.126",
"serde_json",
"serde_urlencoded",
"sha-1",
@ -130,7 +130,7 @@ dependencies = [
"actix-service",
"actix-web",
"futures-util",
"serde 1.0.125",
"serde 1.0.126",
"serde_json",
"time 0.2.26",
]
@ -155,7 +155,7 @@ dependencies = [
"http",
"log",
"regex",
"serde 1.0.125",
"serde 1.0.126",
]
[[package]]
@ -294,7 +294,7 @@ dependencies = [
"mime",
"pin-project 1.0.7",
"regex",
"serde 1.0.125",
"serde 1.0.126",
"serde_json",
"serde_urlencoded",
"socket2",
@ -317,7 +317,7 @@ dependencies = [
[[package]]
name = "actix-web-codegen"
version = "0.5.0-beta.2"
source = "git+https://github.com/realaravinth/actix-web#b91607bfb263d101c4a33b2b9b01b2093c1713d0"
source = "git+https://github.com/realaravinth/actix-web#437a15d3230402b8b8b8343afc48128513814ac9"
dependencies = [
"proc-macro2",
"quote",
@ -407,16 +407,16 @@ version = "0.6.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "796540673305a66d127804eef19ad696f1f204b8c1025aaca4958c17eab32877"
dependencies = [
"getrandom 0.2.2",
"getrandom 0.2.3",
"once_cell",
"version_check",
]
[[package]]
name = "aho-corasick"
version = "0.7.15"
version = "0.7.18"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7404febffaa47dac81aa44dba71523c9d069b1bdc50a77db41195149e17f68e5"
checksum = "1e37cfd5e7657ada45f742d6e99ca5788580b5c529dc78faf11ece6dc702656f"
dependencies = [
"memchr",
]
@ -520,7 +520,7 @@ dependencies = [
"mime",
"percent-encoding",
"rand 0.7.3",
"serde 1.0.125",
"serde 1.0.126",
"serde_json",
"serde_urlencoded",
]
@ -549,7 +549,7 @@ version = "1.3.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b1f45e9417d87227c7a56d22e471c6206462cba514c7590c09aff4cf6d1ddcad"
dependencies = [
"serde 1.0.125",
"serde 1.0.126",
]
[[package]]
@ -652,13 +652,13 @@ dependencies = [
[[package]]
name = "cache-buster"
version = "0.2.0"
source = "git+https://github.com/realaravinth/cache-buster#874dec8180613b6dc654f82c6ef2f6660ec974e6"
source = "git+https://github.com/realaravinth/cache-buster#d970b7031cd90649e30dc297eb5eba74832153e8"
dependencies = [
"data-encoding",
"derive_builder 0.10.2",
"mime",
"mime_guess",
"serde 1.0.125",
"serde 1.0.126",
"serde_json",
"sha2",
"walkdir",
@ -670,7 +670,7 @@ version = "0.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0226944a63d1bf35a3b5f948dd7c59e263db83695c9e8bffc4037de02e30f1d7"
dependencies = [
"serde 1.0.125",
"serde 1.0.126",
]
[[package]]
@ -682,15 +682,15 @@ dependencies = [
"cargo-platform",
"semver 0.11.0",
"semver-parser 0.10.2",
"serde 1.0.125",
"serde 1.0.126",
"serde_json",
]
[[package]]
name = "cc"
version = "1.0.67"
version = "1.0.68"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e3c69b077ad434294d3ce9f1f6143a2a4b89a8a2d54ef813d85003a4fd1137fd"
checksum = "4a72c244c1ff497a746a7e1fb3d14bd08420ecda70c8f25c7112f2781652d787"
[[package]]
name = "cfg-if"
@ -722,7 +722,7 @@ dependencies = [
"lazy_static",
"nom 5.1.2",
"rust-ini",
"serde 1.0.125",
"serde 1.0.126",
"serde-hjson",
"serde_json",
"toml",
@ -731,9 +731,9 @@ dependencies = [
[[package]]
name = "const_fn"
version = "0.4.7"
version = "0.4.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "402da840495de3f976eaefc3485b7f5eb5b0bf9761f9a47be27fe975b3b8c2ec"
checksum = "f92cfa0fd5690b3cf8c1ef2cabbd9b7ef22fa53cf5e1f92b05103f6d5d1cf6e7"
[[package]]
name = "constant_time_eq"
@ -771,10 +771,13 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a2df960f5d869b2dd8532793fde43eb5427cceb126c929747a26823ab0eeb536"
[[package]]
name = "cpuid-bool"
version = "0.1.2"
name = "cpufeatures"
version = "0.1.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8aebca1129a03dc6dc2b127edd729435bbc4a37e1d5f4d7513165089ceb02634"
checksum = "ed00c67cb5d0a7d64a44f6ad2668db7e7530311dd53ea79bcd4fb022c64911c8"
dependencies = [
"libc",
]
[[package]]
name = "cpuid-bool"
@ -1005,9 +1008,9 @@ dependencies = [
[[package]]
name = "derive_more"
version = "0.99.13"
version = "0.99.14"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f82b1b72f1263f214c0f823371768776c4f5841b942c9883aa8e5ec584fd0ba6"
checksum = "5cc7b9cef1e351660e5443924e4f43ab25fbbed3e9a5f052df3677deb4d6b320"
dependencies = [
"convert_case",
"proc-macro2",
@ -1048,7 +1051,7 @@ version = "1.6.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e78d4f1cc4ae33bbfc157ed5d5a5ef3bc29227303d595861deb238fcec4e9457"
dependencies = [
"serde 1.0.125",
"serde 1.0.126",
]
[[package]]
@ -1159,9 +1162,9 @@ dependencies = [
[[package]]
name = "futures"
version = "0.3.14"
version = "0.3.15"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a9d5813545e459ad3ca1bff9915e9ad7f1a47dc6a91b627ce321d5863b7dd253"
checksum = "0e7e43a803dae2fa37c1f6a8fe121e1f7bf9548b4dfc0522a42f34145dadfc27"
dependencies = [
"futures-channel",
"futures-core",
@ -1174,9 +1177,9 @@ dependencies = [
[[package]]
name = "futures-channel"
version = "0.3.14"
version = "0.3.15"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ce79c6a52a299137a6013061e0cf0e688fce5d7f1bc60125f520912fdb29ec25"
checksum = "e682a68b29a882df0545c143dc3646daefe80ba479bcdede94d5a703de2871e2"
dependencies = [
"futures-core",
"futures-sink",
@ -1184,15 +1187,15 @@ dependencies = [
[[package]]
name = "futures-core"
version = "0.3.14"
version = "0.3.15"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "098cd1c6dda6ca01650f1a37a794245eb73181d0d4d4e955e2f3c37db7af1815"
checksum = "0402f765d8a89a26043b889b26ce3c4679d268fa6bb22cd7c6aad98340e179d1"
[[package]]
name = "futures-executor"
version = "0.3.14"
version = "0.3.15"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "10f6cb7042eda00f0049b1d2080aa4b93442997ee507eb3828e8bd7577f94c9d"
checksum = "badaa6a909fac9e7236d0620a2f57f7664640c56575b71a7552fbd68deafab79"
dependencies = [
"futures-core",
"futures-task",
@ -1201,16 +1204,17 @@ dependencies = [
[[package]]
name = "futures-io"
version = "0.3.14"
version = "0.3.15"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "365a1a1fb30ea1c03a830fdb2158f5236833ac81fa0ad12fe35b29cddc35cb04"
checksum = "acc499defb3b348f8d8f3f66415835a9131856ff7714bf10dadfc4ec4bdb29a1"
[[package]]
name = "futures-macro"
version = "0.3.14"
version = "0.3.15"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "668c6733a182cd7deb4f1de7ba3bf2120823835b3bcfbeacf7d2c4a773c1bb8b"
checksum = "a4c40298486cdf52cc00cd6d6987892ba502c7656a16a4192a9992b1ccedd121"
dependencies = [
"autocfg",
"proc-macro-hack",
"proc-macro2",
"quote",
@ -1219,22 +1223,23 @@ dependencies = [
[[package]]
name = "futures-sink"
version = "0.3.14"
version = "0.3.15"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5c5629433c555de3d82861a7a4e3794a4c40040390907cfbfd7143a92a426c23"
checksum = "a57bead0ceff0d6dde8f465ecd96c9338121bb7717d3e7b108059531870c4282"
[[package]]
name = "futures-task"
version = "0.3.14"
version = "0.3.15"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ba7aa51095076f3ba6d9a1f702f74bd05ec65f555d70d2033d55ba8d69f581bc"
checksum = "8a16bef9fc1a4dddb5bee51c989e3fbba26569cbb0e31f5b303c184e3dd33dae"
[[package]]
name = "futures-util"
version = "0.3.14"
version = "0.3.15"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3c144ad54d60f23927f0a6b6d816e4271278b64f005ad65e4e35291d2de9c025"
checksum = "feb5c238d27e2bf94ffdfd27b2c29e3df4a68c4193bb6427384259e2bf191967"
dependencies = [
"autocfg",
"futures-channel",
"futures-core",
"futures-io",
@ -1281,9 +1286,9 @@ dependencies = [
[[package]]
name = "getrandom"
version = "0.2.2"
version = "0.2.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c9495705279e7140bf035dde1f6e750c162df8b625267cd52cc44e0b156732c8"
checksum = "7fcd999463524c52659517fe2cea98493cfe485d10565e7b0fb07dbba7ad2753"
dependencies = [
"cfg-if 1.0.0",
"libc",
@ -1328,7 +1333,7 @@ dependencies = [
"rand 0.8.3",
"rust-embed",
"sailfish",
"serde 1.0.125",
"serde 1.0.126",
"serde_json",
"serde_yaml",
"sqlx",
@ -1466,9 +1471,9 @@ dependencies = [
[[package]]
name = "httparse"
version = "1.4.0"
version = "1.4.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4a1ce40d6fc9764887c2fdc7305c3dcc429ba11ff981c1509416afd5697e4437"
checksum = "f3a87b616e37e93c22fb19bcd386f02f3af5ea98a25670ad0fce773de23c5e68"
[[package]]
name = "humantime"
@ -1556,9 +1561,9 @@ checksum = "9028f49264629065d057f340a86acb84867925865f73bbf8d47b4d149a7e88b8"
[[package]]
name = "js-sys"
version = "0.3.50"
version = "0.3.51"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2d99f9e3e84b8f67f846ef5b4cbbc3b1c29f6c759fcbce6f01aa0e73d932a24c"
checksum = "83bdfbace3a0e81a4253f73b49e960b053e396a11012cbd49b9b74d6a2b67062"
dependencies = [
"wasm-bindgen",
]
@ -1612,9 +1617,9 @@ checksum = "7fb9b38af92608140b86b693604b9ffcc5824240a484d1ecd4795bacb2fe88f3"
[[package]]
name = "lock_api"
version = "0.4.3"
version = "0.4.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5a3c91c24eae6777794bb1997ad98bbb87daf92890acab859f7eaa4320333176"
checksum = "0382880606dff6d15c9476c416d18690b72742aa7b605bb6dd6ec9030fbf07eb"
dependencies = [
"scopeguard",
]
@ -1640,7 +1645,7 @@ dependencies = [
[[package]]
name = "m_captcha"
version = "0.1.3"
source = "git+https://github.com/mCaptcha/mCaptcha?branch=master#29cd8f4fd83a3646a48ca2c9f5563d8d5360d2c3"
source = "git+https://github.com/mCaptcha/mCaptcha?branch=master#8f0f0daf1e1cb36c848cada1c24dc3799d1e31b4"
dependencies = [
"actix",
"derive_builder 0.9.0",
@ -1649,7 +1654,7 @@ dependencies = [
"pow_sha256",
"pretty_env_logger",
"rand 0.8.3",
"serde 1.0.125",
"serde 1.0.126",
"serde_json",
]
@ -1722,9 +1727,9 @@ dependencies = [
[[package]]
name = "memchr"
version = "2.3.4"
version = "2.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0ee1c47aaa256ecabcaea351eae4a9b01ef39ed810004e298d2511ed284b1525"
checksum = "b16bd47d9e329435e309c58469fe0791c2d0d1ba96ec0954152a5ae2b04387dc"
[[package]]
name = "mime"
@ -1835,6 +1840,75 @@ dependencies = [
"version_check",
]
[[package]]
name = "num"
version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "43db66d1170d347f9a065114077f7dccb00c1b9478c89384490a3425279a4606"
dependencies = [
"num-bigint",
"num-complex",
"num-integer",
"num-iter",
"num-rational",
"num-traits 0.2.14",
]
[[package]]
name = "num-bigint"
version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4e0d047c1062aa51e256408c560894e5251f08925980e53cf1aa5bd00eec6512"
dependencies = [
"autocfg",
"num-integer",
"num-traits 0.2.14",
"serde 1.0.126",
]
[[package]]
name = "num-complex"
version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "26873667bbbb7c5182d4a37c1add32cdf09f841af72da53318fdb81543c15085"
dependencies = [
"num-traits 0.2.14",
"serde 1.0.126",
]
[[package]]
name = "num-integer"
version = "0.1.44"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d2cc698a63b549a70bc047073d2949cce27cd1c7b0a4a862d08a8031bc2801db"
dependencies = [
"autocfg",
"num-traits 0.2.14",
]
[[package]]
name = "num-iter"
version = "0.1.42"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b2021c8337a54d21aca0d59a92577a029af9431cb59b909b03252b9c164fad59"
dependencies = [
"autocfg",
"num-integer",
"num-traits 0.2.14",
]
[[package]]
name = "num-rational"
version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d41702bd167c2df5520b384281bc111a4b5efcf7fbc4c9c222c815b07e0a6a6a"
dependencies = [
"autocfg",
"num-integer",
"num-traits 0.2.14",
"serde 1.0.126",
]
[[package]]
name = "num-traits"
version = "0.1.43"
@ -2017,7 +2091,7 @@ version = "0.4.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "eebcc4aa140b9abd2bc40d9c3f7ccec842679cd79045ac3a7ac698c1a064b7cd"
dependencies = [
"cpuid-bool 0.2.0",
"cpuid-bool",
"opaque-debug",
"universal-hash",
]
@ -2025,11 +2099,12 @@ dependencies = [
[[package]]
name = "pow_sha256"
version = "0.2.1"
source = "git+https://github.com/mcaptcha/pow_sha256#f97858cd639fa2f807603d2515a6ae09191629cd"
source = "git+https://github.com/mcaptcha/pow_sha256#8df560aaa85530f7824070d7d9d839d8cf6d0411"
dependencies = [
"bincode",
"derive_builder 0.10.2",
"serde 1.0.125",
"num",
"serde 1.0.126",
"sha2",
]
@ -2182,7 +2257,7 @@ version = "0.6.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "34cf66eb183df1c5876e2dcf6b13d57340741e8dc255b48e40a26de954d06ae7"
dependencies = [
"getrandom 0.2.2",
"getrandom 0.2.3",
]
[[package]]
@ -2214,18 +2289,18 @@ dependencies = [
[[package]]
name = "redox_syscall"
version = "0.2.7"
version = "0.2.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "85dd92e586f7355c633911e11f77f3d12f04b1b1bd76a198bd34ae3af8341ef2"
checksum = "742739e41cd49414de871ea5e549afb7e2a3ac77b589bcbebe8c82fab37147fc"
dependencies = [
"bitflags",
]
[[package]]
name = "regex"
version = "1.4.6"
version = "1.5.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2a26af418b574bd56588335b3a3659a65725d4e636eb1016c2f9e3b38c7cc759"
checksum = "d07a8629359eb56f1e2fb1652bb04212c072a87ba68546a04065d525673ac461"
dependencies = [
"aho-corasick",
"memchr",
@ -2234,9 +2309,9 @@ dependencies = [
[[package]]
name = "regex-syntax"
version = "0.6.23"
version = "0.6.25"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "24d5f089152e60f62d28b835fbff2cd2e8dc0baf1ac13343bef92ab7eed84548"
checksum = "f497285884f3fcff424ffc933e56d7cbca511def0c9831a7f9b5f6153e3cc89b"
[[package]]
name = "resolv-conf"
@ -2420,7 +2495,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f301af10236f6df4160f7c3f04eec6dbc70ace82d23326abad5edee88801c6b6"
dependencies = [
"semver-parser 0.10.2",
"serde 1.0.125",
"serde 1.0.126",
]
[[package]]
@ -2446,9 +2521,9 @@ checksum = "9dad3f759919b92c3068c696c15c3d17238234498bbdcc80f2c469606f948ac8"
[[package]]
name = "serde"
version = "1.0.125"
version = "1.0.126"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "558dc50e1a5a5fa7112ca2ce4effcb321b0300c0d4ccf0776a9f60cd89031171"
checksum = "ec7505abeacaec74ae4778d9d9328fe5a5d04253220a85c4ee022239fc996d03"
dependencies = [
"serde_derive",
]
@ -2467,9 +2542,9 @@ dependencies = [
[[package]]
name = "serde_derive"
version = "1.0.125"
version = "1.0.126"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b093b7a2bb58203b5da3056c05b4ec1fed827dcfdb37347a8841695263b3d06d"
checksum = "963a7dbc9895aeac7ac90e74f34a5d5261828f79df35cbed41e10189d3804d43"
dependencies = [
"proc-macro2",
"quote",
@ -2485,7 +2560,7 @@ dependencies = [
"indexmap",
"itoa",
"ryu",
"serde 1.0.125",
"serde 1.0.126",
]
[[package]]
@ -2497,7 +2572,7 @@ dependencies = [
"form_urlencoded",
"itoa",
"ryu",
"serde 1.0.125",
"serde 1.0.126",
]
[[package]]
@ -2508,19 +2583,19 @@ checksum = "15654ed4ab61726bf918a39cb8d98a2e2995b002387807fa6ba58fdf7f59bb23"
dependencies = [
"dtoa",
"linked-hash-map",
"serde 1.0.125",
"serde 1.0.126",
"yaml-rust",
]
[[package]]
name = "sha-1"
version = "0.9.4"
version = "0.9.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "dfebf75d25bd900fd1e7d11501efab59bc846dbc76196839663e6637bba9f25f"
checksum = "8c4cfa741c5832d0ef7fab46cabed29c2aae926db0b11bb2069edd8db5e64e16"
dependencies = [
"block-buffer",
"cfg-if 1.0.0",
"cpuid-bool 0.1.2",
"cpufeatures",
"digest",
"opaque-debug",
]
@ -2533,13 +2608,13 @@ checksum = "2579985fda508104f7587689507983eadd6a6e84dd35d6d115361f530916fa0d"
[[package]]
name = "sha2"
version = "0.9.3"
version = "0.9.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fa827a14b29ab7f44778d14a88d3cb76e949c45083f7dbfa507d0cb699dc12de"
checksum = "b362ae5752fd2137731f9fa25fd4d9058af34666ca1966fb969119cc35719f12"
dependencies = [
"block-buffer",
"cfg-if 1.0.0",
"cpuid-bool 0.1.2",
"cpufeatures",
"digest",
"opaque-debug",
]
@ -2644,7 +2719,7 @@ dependencies = [
"percent-encoding",
"rand 0.7.3",
"rustls",
"serde 1.0.125",
"serde 1.0.126",
"sha-1",
"sha2",
"smallvec",
@ -2674,7 +2749,7 @@ dependencies = [
"lazy_static",
"proc-macro2",
"quote",
"serde 1.0.125",
"serde 1.0.126",
"serde_json",
"sha2",
"sqlx-core",
@ -2733,7 +2808,7 @@ checksum = "c87a60a40fccc84bef0652345bbbbbe20a605bf5d0ce81719fc476f5c03b50ef"
dependencies = [
"proc-macro2",
"quote",
"serde 1.0.125",
"serde 1.0.126",
"serde_derive",
"syn",
]
@ -2747,7 +2822,7 @@ dependencies = [
"base-x",
"proc-macro2",
"quote",
"serde 1.0.125",
"serde 1.0.126",
"serde_derive",
"serde_json",
"sha1",
@ -2770,7 +2845,7 @@ dependencies = [
"new_debug_unreachable",
"phf_shared",
"precomputed-hash",
"serde 1.0.125",
"serde 1.0.126",
]
[[package]]
@ -2815,9 +2890,9 @@ checksum = "1e81da0851ada1f3e9d4312c704aa4f8806f0f9d69faaf8df2f3464b4a9437c2"
[[package]]
name = "syn"
version = "1.0.71"
version = "1.0.72"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ad184cc9470f9117b2ac6817bfe297307418819ba40552f9b3846f05c33d5373"
checksum = "a1e8cdbefb79a9a5a65e0db8b47b723ee907b7c7f8496c76a1770b5c310bab82"
dependencies = [
"proc-macro2",
"quote",
@ -2852,18 +2927,18 @@ dependencies = [
[[package]]
name = "thiserror"
version = "1.0.24"
version = "1.0.25"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e0f4a65597094d4483ddaed134f409b2cb7c1beccf25201a9f73c719254fa98e"
checksum = "fa6f76457f59514c7eeb4e59d891395fab0b2fd1d40723ae737d64153392e9c6"
dependencies = [
"thiserror-impl",
]
[[package]]
name = "thiserror-impl"
version = "1.0.24"
version = "1.0.25"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7765189610d8241a44529806d6fd1f2e0a08734313a35d5b3a556f92b381f3c0"
checksum = "8a36768c0fbf1bb15eca10defa29526bda730a2376c2ab4393ccfa16fb1a318d"
dependencies = [
"proc-macro2",
"quote",
@ -3009,14 +3084,14 @@ version = "0.5.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a31142970826733df8241ef35dc040ef98c679ab14d7c3e54d827099b3acecaa"
dependencies = [
"serde 1.0.125",
"serde 1.0.126",
]
[[package]]
name = "tracing"
version = "0.1.25"
version = "0.1.26"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "01ebdc2bb4498ab1ab5f5b73c5803825e60199229ccba0698170e3be0e7f959f"
checksum = "09adeb8c97449311ccd28a427f96fb563e7fd31aabf994189879d9da2394b89d"
dependencies = [
"cfg-if 1.0.0",
"log",
@ -3026,9 +3101,9 @@ dependencies = [
[[package]]
name = "tracing-core"
version = "0.1.17"
version = "0.1.18"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f50de3927f93d202783f4513cda820ab47ef17f624b03c096e86ef00c67e6b5f"
checksum = "a9ff14f98b1a4b289c6248a023c1c2fa1491062964e9fed67ab29c4e4da4a052"
dependencies = [
"lazy_static",
]
@ -3157,9 +3232,9 @@ checksum = "a156c684c91ea7d62626509bce3cb4e1d9ed5c4d978f7b4352658f96a4c26b4a"
[[package]]
name = "url"
version = "2.2.1"
version = "2.2.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9ccd964113622c8e9322cfac19eb1004a07e636c545f325da085d5cdde6f1f8b"
checksum = "a507c383b2d33b5fc35d1861e77e6b383d158b2da5e14fe51b83dfedf6fd578c"
dependencies = [
"form_urlencoded",
"idna",
@ -3182,7 +3257,7 @@ dependencies = [
"idna",
"lazy_static",
"regex",
"serde 1.0.125",
"serde 1.0.126",
"serde_derive",
"serde_json",
"url",
@ -3243,9 +3318,9 @@ checksum = "fd6fbd9a79829dd1ad0cc20627bf1ed606756a7f77edff7b66b7064f9cb327c6"
[[package]]
name = "wasm-bindgen"
version = "0.2.73"
version = "0.2.74"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "83240549659d187488f91f33c0f8547cbfef0b2088bc470c116d1d260ef623d9"
checksum = "d54ee1d4ed486f78874278e63e4069fc1ab9f6a18ca492076ffb90c5eb2997fd"
dependencies = [
"cfg-if 1.0.0",
"wasm-bindgen-macro",
@ -3253,9 +3328,9 @@ dependencies = [
[[package]]
name = "wasm-bindgen-backend"
version = "0.2.73"
version = "0.2.74"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ae70622411ca953215ca6d06d3ebeb1e915f0f6613e3b495122878d7ebec7dae"
checksum = "3b33f6a0694ccfea53d94db8b2ed1c3a8a4c86dd936b13b9f0a15ec4a451b900"
dependencies = [
"bumpalo",
"lazy_static",
@ -3268,9 +3343,9 @@ dependencies = [
[[package]]
name = "wasm-bindgen-macro"
version = "0.2.73"
version = "0.2.74"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3e734d91443f177bfdb41969de821e15c516931c3c3db3d318fa1b68975d0f6f"
checksum = "088169ca61430fe1e58b8096c24975251700e7b1f6fd91cc9d59b04fb9b18bd4"
dependencies = [
"quote",
"wasm-bindgen-macro-support",
@ -3278,9 +3353,9 @@ dependencies = [
[[package]]
name = "wasm-bindgen-macro-support"
version = "0.2.73"
version = "0.2.74"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d53739ff08c8a68b0fdbcd54c372b8ab800b1449ab3c9d706503bc7dd1621b2c"
checksum = "be2241542ff3d9f241f5e2cb6dd09b37efe786df8851c54957683a49f0987a97"
dependencies = [
"proc-macro2",
"quote",
@ -3291,15 +3366,15 @@ dependencies = [
[[package]]
name = "wasm-bindgen-shared"
version = "0.2.73"
version = "0.2.74"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d9a543ae66aa233d14bb765ed9af4a33e81b8b58d1584cf1b47ff8cd0b9e4489"
checksum = "d7cff876b8f18eed75a66cf49b65e7f967cb354a7aa16003fb55dbfd25b44b4f"
[[package]]
name = "web-sys"
version = "0.3.50"
version = "0.3.51"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a905d57e488fec8861446d3393670fb50d27a262344013181c2cdf9fff5481be"
checksum = "e828417b379f3df7111d3a2a9e5753706cae29c41f7c4029ee9fd77f3e09e582"
dependencies = [
"js-sys",
"wasm-bindgen",

View file

@ -22,6 +22,7 @@ use super::auth::Password;
use crate::errors::*;
use crate::Data;
#[my_codegen::post(path="crate::V1_API_ROUTES.account.delete", wrap="crate::CheckLogin")]
async fn delete_account(
id: Identity,
payload: web::Json<Password>,
@ -59,13 +60,14 @@ async fn delete_account(
}
pub fn services(cfg: &mut actix_web::web::ServiceConfig) {
use crate::define_resource;
use crate::V1_API_ROUTES;
define_resource!(
cfg,
V1_API_ROUTES.account.delete,
Methods::ProtectPost,
delete_account
);
cfg.service(delete_account);
// use crate::define_resource;
// use crate::V1_API_ROUTES;
//
// define_resource!(
// cfg,
// V1_API_ROUTES.account.delete,
// Methods::ProtectPost,
// delete_account
// );
}

View file

@ -29,6 +29,7 @@ pub struct Email {
pub email: String,
}
#[my_codegen::post(path="crate::V1_API_ROUTES.account.email_exists")]
pub async fn email_exists(
payload: web::Json<AccountCheckPayload>,
data: web::Data<Data>,
@ -52,6 +53,7 @@ pub async fn email_exists(
}
/// update email
#[my_codegen::post(path="crate::V1_API_ROUTES.account.update_email", wrap="crate::CheckLogin")]
async fn set_email(
id: Identity,
payload: web::Json<Email>,
@ -84,20 +86,22 @@ async fn set_email(
}
pub fn services(cfg: &mut actix_web::web::ServiceConfig) {
use crate::define_resource;
use crate::V1_API_ROUTES;
define_resource!(
cfg,
V1_API_ROUTES.account.email_exists,
Methods::Post,
email_exists
);
define_resource!(
cfg,
V1_API_ROUTES.account.update_email,
Methods::Post,
set_email
);
cfg.service(email_exists);
cfg.service(set_email);
// use crate::define_resource;
// use crate::V1_API_ROUTES;
//
// define_resource!(
// cfg,
// V1_API_ROUTES.account.email_exists,
// Methods::Post,
// email_exists
// );
//
// define_resource!(
// cfg,
// V1_API_ROUTES.account.update_email,
// Methods::Post,
// set_email
// );
}

View file

@ -29,6 +29,7 @@ pub struct Secret {
pub secret: String,
}
#[my_codegen::get(path="crate::V1_API_ROUTES.account.get_secret", wrap="crate::CheckLogin")]
async fn get_secret(
id: Identity,
data: web::Data<Data>,
@ -46,6 +47,7 @@ async fn get_secret(
Ok(HttpResponse::Ok().json(secret))
}
#[my_codegen::post(path="crate::V1_API_ROUTES.account.update_secret", wrap="crate::CheckLogin")]
async fn update_user_secret(
id: Identity,
data: web::Data<Data>,
@ -82,20 +84,6 @@ async fn update_user_secret(
}
pub fn services(cfg: &mut actix_web::web::ServiceConfig) {
use crate::define_resource;
use crate::V1_API_ROUTES;
define_resource!(
cfg,
V1_API_ROUTES.account.get_secret,
Methods::ProtectGet,
get_secret
);
define_resource!(
cfg,
V1_API_ROUTES.account.update_secret,
Methods::ProtectPost,
update_user_secret
);
cfg.service(get_secret);
cfg.service(update_user_secret);
}

View file

@ -20,6 +20,7 @@ use super::{AccountCheckPayload, AccountCheckResp};
use crate::errors::*;
use crate::Data;
#[my_codegen::post(path="crate::V1_API_ROUTES.account.username_exists")]
async fn username_exists(
payload: web::Json<AccountCheckPayload>,
data: web::Data<Data>,
@ -43,13 +44,5 @@ async fn username_exists(
}
pub fn services(cfg: &mut actix_web::web::ServiceConfig) {
use crate::define_resource;
use crate::V1_API_ROUTES;
define_resource!(
cfg,
V1_API_ROUTES.account.username_exists,
Methods::Post,
username_exists
);
cfg.service(username_exists);
}

View file

@ -25,9 +25,6 @@ use serde::{Deserialize, Serialize};
use super::mcaptcha::get_random;
use crate::errors::*;
use crate::Data;
use crate::*;
pub const AUTH: routes::Auth = routes::Auth::new();
pub mod routes {
pub struct Auth {
@ -50,16 +47,17 @@ pub mod routes {
}
}
//post!(V1_API_ROUTES.auth.register, signup);
pub fn services(cfg: &mut web::ServiceConfig) {
// protect_get!(cfg, V1_API_ROUTES.auth.logout, signout);
//cfg.service(signup);
cfg.service(signup);
cfg.service(signin);
cfg.service(signout);
define_resource!(cfg, V1_API_ROUTES.auth.register, Methods::Post, signup);
define_resource!(cfg, V1_API_ROUTES.auth.logout, Methods::ProtectGet, signout);
define_resource!(cfg, V1_API_ROUTES.auth.login, Methods::Post, signin);
// define_resource!(cfg, V1_API_ROUTES.auth.register, Methods::Post, signup);
// define_resource!(cfg, V1_API_ROUTES.auth.logout, Methods::ProtectGet, signout);
// define_resource!(cfg, V1_API_ROUTES.auth.login, Methods::Post, signin);
//post!(cfg, V1_API_ROUTES.auth.login, signin);
}
@ -82,6 +80,7 @@ pub struct Password {
pub password: String,
}
#[my_codegen::post(path="crate::V1_API_ROUTES.auth.register")]
async fn signup(
payload: web::Json<Register>,
data: web::Data<Data>,
@ -127,8 +126,7 @@ async fn signup(
.execute(&data.db)
.await;
}
if res.is_ok() {
break;
if res.is_ok() { break;
} else {
if let Err(sqlx::Error::Database(err)) = res {
if err.code() == Some(Cow::from("23505")) {
@ -149,6 +147,7 @@ async fn signup(
Ok(HttpResponse::Ok())
}
#[my_codegen::post(path="crate::V1_API_ROUTES.auth.login")]
async fn signin(
id: Identity,
payload: web::Json<Login>,
@ -180,6 +179,7 @@ async fn signin(
}
}
#[my_codegen::get(path="crate::V1_API_ROUTES.auth.logout", wrap="crate::CheckLogin")]
async fn signout(id: Identity) -> impl Responder {
if let Some(_) = id.identity() {
id.forget();

View file

@ -44,6 +44,7 @@ pub struct UpdateDuration {
pub duration: i32,
}
#[my_codegen::post(path="crate::V1_API_ROUTES.duration.update", wrap="crate::CheckLogin")]
async fn update_duration(
payload: web::Json<UpdateDuration>,
data: web::Data<Data>,
@ -81,6 +82,7 @@ pub struct GetDuration {
pub token: String,
}
#[my_codegen::post(path="crate::V1_API_ROUTES.duration.get", wrap="crate::CheckLogin")]
async fn get_duration(
payload: web::Json<MCaptchaDetails>,
data: web::Data<Data>,
@ -101,21 +103,23 @@ async fn get_duration(
}
pub fn services(cfg: &mut web::ServiceConfig) {
use crate::define_resource;
use crate::V1_API_ROUTES;
define_resource!(
cfg,
V1_API_ROUTES.duration.get,
Methods::ProtectPost,
get_duration
);
define_resource!(
cfg,
V1_API_ROUTES.duration.update,
Methods::ProtectPost,
update_duration
);
cfg.service(get_duration);
cfg.service(update_duration);
// use crate::define_resource;
// use crate::V1_API_ROUTES;
//
// define_resource!(
// cfg,
// V1_API_ROUTES.duration.get,
// Methods::ProtectPost,
// get_duration
// );
// define_resource!(
// cfg,
// V1_API_ROUTES.duration.update,
// Methods::ProtectPost,
// update_duration
// );
}
#[cfg(test)]

View file

@ -59,39 +59,15 @@ pub struct AddLevels {
}
pub fn services(cfg: &mut web::ServiceConfig) {
use crate::define_resource;
use crate::V1_API_ROUTES;
define_resource!(
cfg,
V1_API_ROUTES.levels.add,
Methods::ProtectPost,
add_levels
);
define_resource!(
cfg,
V1_API_ROUTES.levels.update,
Methods::ProtectPost,
update_levels
);
define_resource!(
cfg,
V1_API_ROUTES.levels.delete,
Methods::ProtectPost,
delete_levels
);
define_resource!(
cfg,
V1_API_ROUTES.levels.get,
Methods::ProtectPost,
get_levels
);
cfg.service(add_levels);
cfg.service(update_levels);
cfg.service(delete_levels);
cfg.service(get_levels);
}
// TODO redo mcaptcha table to include levels as json field
// so that the whole thing can be added/udpaed in a single stroke
#[my_codegen::post(path="crate::V1_API_ROUTES.levels.add", wrap="crate::CheckLogin")]
async fn add_levels(
payload: web::Json<AddLevels>,
data: web::Data<Data>,
@ -144,6 +120,7 @@ pub struct UpdateLevels {
pub key: String,
}
#[my_codegen::post(path="crate::V1_API_ROUTES.levels.update", wrap="crate::CheckLogin")]
async fn update_levels(
payload: web::Json<UpdateLevels>,
data: web::Data<Data>,
@ -201,6 +178,7 @@ async fn update_levels(
Ok(HttpResponse::Ok())
}
#[my_codegen::post(path="crate::V1_API_ROUTES.levels.delete", wrap="crate::CheckLogin")]
async fn delete_levels(
payload: web::Json<UpdateLevels>,
data: web::Data<Data>,
@ -227,6 +205,7 @@ async fn delete_levels(
Ok(HttpResponse::Ok())
}
#[my_codegen::post(path="crate::V1_API_ROUTES.levels.get", wrap="crate::CheckLogin")]
async fn get_levels(
payload: web::Json<MCaptchaDetails>,
data: web::Data<Data>,

View file

@ -43,29 +43,9 @@ pub mod routes {
}
pub fn services(cfg: &mut web::ServiceConfig) {
use crate::define_resource;
use crate::V1_API_ROUTES;
define_resource!(
cfg,
V1_API_ROUTES.mcaptcha.update_key,
Methods::ProtectPost,
update_token
);
define_resource!(
cfg,
V1_API_ROUTES.mcaptcha.delete,
Methods::ProtectPost,
delete_mcaptcha
);
define_resource!(
cfg,
V1_API_ROUTES.mcaptcha.get_token,
Methods::ProtectPost,
get_token
);
cfg.service(update_token);
cfg.service(delete_mcaptcha);
cfg.service(get_token);
}
#[derive(Clone, Debug, Deserialize, Serialize)]
@ -131,6 +111,7 @@ pub async fn add_mcaptcha_util(
Ok(resp)
}
#[my_codegen::post(path="crate::V1_API_ROUTES.mcaptcha.update_key", wrap="crate::CheckLogin")]
async fn update_token(
payload: web::Json<MCaptchaDetails>,
data: web::Data<Data>,
@ -181,6 +162,7 @@ async fn update_token_helper(
Ok(())
}
#[my_codegen::post(path="crate::V1_API_ROUTES.mcaptcha.get_token", wrap="crate::CheckLogin")]
async fn get_token(
payload: web::Json<MCaptchaDetails>,
data: web::Data<Data>,
@ -208,6 +190,7 @@ async fn get_token(
Ok(HttpResponse::Ok().json(res))
}
#[my_codegen::post(path="crate::V1_API_ROUTES.mcaptcha.delete", wrap="crate::CheckLogin")]
async fn delete_mcaptcha(
payload: web::Json<MCaptchaDetails>,
data: web::Data<Data>,

View file

@ -45,6 +45,7 @@ pub mod routes {
}
/// emmits build details of the bninary
#[my_codegen::get(path="crate::V1_API_ROUTES.meta.build_details")]
async fn build_details() -> impl Responder {
let build = BuildDetails {
version: VERSION,
@ -60,6 +61,7 @@ pub struct Health {
}
/// checks all components of the system
#[my_codegen::get(path="crate::V1_API_ROUTES.meta.health")]
async fn health(data: web::Data<Data>) -> impl Responder {
use sqlx::Connection;
@ -75,16 +77,8 @@ async fn health(data: web::Data<Data>) -> impl Responder {
}
pub fn services(cfg: &mut web::ServiceConfig) {
use crate::define_resource;
use crate::V1_API_ROUTES;
define_resource!(
cfg,
V1_API_ROUTES.meta.build_details,
Methods::Get,
build_details
);
define_resource!(cfg, V1_API_ROUTES.meta.health, Methods::Get, health);
cfg.service(build_details);
cfg.service(health);
}
#[cfg(test)]

View file

@ -30,6 +30,7 @@ pub struct AddNotification {
}
/// route handler that adds a notification message
#[my_codegen::post(path="crate::V1_API_ROUTES.notifications.add", wrap="crate::CheckLogin")]
pub async fn add_notification(
payload: web::Json<AddNotification>,
data: web::Data<Data>,

View file

@ -52,6 +52,7 @@ impl From<Notification> for NotificationResp {
}
}
/// route handler that gets all unread notifications
#[my_codegen::get(path="crate::V1_API_ROUTES.notifications.get", wrap="crate::CheckLogin")]
pub async fn get_notification(
data: web::Data<Data>,
id: Identity,

View file

@ -38,20 +38,6 @@ pub mod routes {
}
pub fn services(cfg: &mut actix_web::web::ServiceConfig) {
use crate::define_resource;
use crate::V1_API_ROUTES;
define_resource!(
cfg,
V1_API_ROUTES.notifications.add,
Methods::ProtectPost,
add::add_notification
);
define_resource!(
cfg,
V1_API_ROUTES.notifications.get,
Methods::ProtectGet,
get::get_notification
);
cfg.service(add::add_notification);
cfg.service(get::get_notification);
}

View file

@ -27,6 +27,7 @@ use super::GetDurationResp;
use super::I32Levels;
use crate::errors::*;
use crate::Data;
use crate::V1_API_ROUTES;
//#[derive(Clone, Debug, Deserialize, Serialize)]
//pub struct PoWConfig {
@ -42,6 +43,7 @@ pub struct GetConfigPayload {
// API keys are mcaptcha actor names
/// get PoW configuration for an mcaptcha key
#[my_codegen::post(path = "V1_API_ROUTES.pow.get_config.strip_prefix(V1_API_ROUTES.pow.scope).unwrap()")]
pub async fn get_config(
payload: web::Json<GetConfigPayload>,
data: web::Data<Data>,
@ -80,6 +82,7 @@ pub async fn get_config(
Some(false) => Err(ServiceError::TokenNotFound),
None => Err(ServiceError::TokenNotFound),
}
}
/// Call this when [MCaptcha][m_captcha::MCaptcha] is not in master.
///

View file

@ -15,7 +15,6 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
use actix_cors::Cors;
use actix_web::web;
use actix_web::*;
@ -28,28 +27,19 @@ pub use super::mcaptcha::levels::I32Levels;
use crate::api::v1::mcaptcha::stats::*;
pub fn services(cfg: &mut web::ServiceConfig) {
use crate::define_resource;
use crate::V1_API_ROUTES;
let cors = actix_cors::Cors::default()
.allow_any_origin()
.allowed_methods(vec!["POST"])
.allow_any_header()
.max_age(3600)
.send_wildcard();
define_resource!(
cfg,
V1_API_ROUTES.pow.verify_pow,
Methods::CorsAllowAllPost,
verify_pow::verify_pow
);
define_resource!(
cfg,
V1_API_ROUTES.pow.get_config,
Methods::CorsAllowAllPost,
get_config::get_config
);
define_resource!(
cfg,
V1_API_ROUTES.pow.validate_captcha_token,
Methods::CorsAllowAllPost,
verify_token::validate_captcha_token
cfg.service(
Scope::new(crate::V1_API_ROUTES.pow.scope)
.wrap(cors)
.service(verify_pow::verify_pow)
.service(get_config::get_config)
.service(verify_token::validate_captcha_token),
);
}
@ -58,30 +48,48 @@ pub mod routes {
pub get_config: &'static str,
pub verify_pow: &'static str,
pub validate_captcha_token: &'static str,
pub scope: &'static str,
}
impl PoW {
pub const fn new() -> Self {
let scope = "/api/v1/pow/";
PoW {
get_config: "/api/v1/pow/config",
verify_pow: "/api/v1/pow/verify",
validate_captcha_token: "/api/v1/pow/siteverify",
scope,
}
}
}
}
}
//#[allow(non_camel_case_types, missing_docs)]
//pub struct post;
//impl actix_web::dev::HttpServiceFactory for post {
// fn register(self, __config: &mut actix_web::dev::AppService) {
// async fn post() -> impl Responder {
// HttpResponse::Ok()
// }
// let __resource = actix_web::Resource::new("/test/post")
// .guard(actix_web::guard::Post())
// .to(post);
// actix_web::dev::HttpServiceFactory::register(__resource, __config)
// }
//}
#[allow(non_camel_case_types, missing_docs)]
pub struct post;
impl actix_web::dev::HttpServiceFactory for post {
fn register(self, __config: &mut actix_web::dev::AppService) {
async fn post() -> impl Responder {
HttpResponse::Ok()
}
let __resource = actix_web::Resource::new("/test/post")
.guard(actix_web::guard::Post())
.to(post);
actix_web::dev::HttpServiceFactory::register(__resource, __config)
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn scope_pow_works() {
let pow = routes::PoW::new();
assert_eq!(pow.get_config.strip_prefix(pow.scope).unwrap(), "config");
assert_eq!(pow.verify_pow.strip_prefix(pow.scope).unwrap(), "verify");
assert_eq!(
pow.validate_captcha_token.strip_prefix(pow.scope).unwrap(),
"siteverify"
);
}
}

View file

@ -23,6 +23,7 @@ use serde::{Deserialize, Serialize};
use super::record_solve;
use crate::errors::*;
use crate::Data;
use crate::V1_API_ROUTES;
#[derive(Clone, Debug, Deserialize, Serialize)]
/// validation token that clients receive as proof for submiting
@ -35,6 +36,7 @@ pub struct ValidationToken {
/// route handler that verifies PoW and issues a solution token
/// if verification is successful
#[my_codegen::post(path = "V1_API_ROUTES.pow.verify_pow.strip_prefix(V1_API_ROUTES.pow.scope).unwrap()")]
pub async fn verify_pow(
payload: web::Json<Work>,
data: web::Data<Data>,

View file

@ -23,6 +23,7 @@ use serde::{Deserialize, Serialize};
use super::record_confirm;
use crate::errors::*;
use crate::Data;
use crate::V1_API_ROUTES;
#[derive(Clone, Debug, Deserialize, Serialize)]
pub struct CaptchaValidateResp {
@ -32,6 +33,7 @@ pub struct CaptchaValidateResp {
// API keys are mcaptcha actor names
/// route hander that validates a PoW solution token
#[my_codegen::post(path = "V1_API_ROUTES.pow.validate_captcha_token.strip_prefix(V1_API_ROUTES.pow.scope).unwrap()")]
pub async fn validate_captcha_token(
payload: web::Json<VerifyCaptchaResult>,
data: web::Data<Data>,

View file

@ -37,11 +37,8 @@ lazy_static! {
static ref INDEX: String = IndexPage::default().render_once().unwrap();
}
const ROUTE: &str = PAGES.auth.login;
#[get(path="ROUTE")]
#[get(path="PAGES.auth.login")]
pub async fn login() -> impl Responder {
struct Foo;
HttpResponse::Ok()
.content_type("text/html; charset=utf-8")
.body(&*INDEX)

View file

@ -19,12 +19,8 @@ pub mod login;
pub mod register;
pub fn services(cfg: &mut actix_web::web::ServiceConfig) {
use crate::define_resource;
use crate::PAGES;
cfg.service(login::login);
// define_resource!(cfg, PAGES.auth.login, Methods::Get, login::login);
define_resource!(cfg, PAGES.auth.join, Methods::Get, register::join);
cfg.service(register::join);
}
pub mod routes {

View file

@ -35,6 +35,7 @@ lazy_static! {
static ref INDEX: String = IndexPage::default().render_once().unwrap();
}
#[my_codegen::get(path = "crate::PAGES.auth.join")]
pub async fn join() -> impl Responder {
HttpResponse::Ok()
.content_type("text/html; charset=utf-8")

View file

@ -39,6 +39,7 @@ impl IndexPage {
const PAGE: &str = "Dashboard";
#[my_codegen::get(path = "crate::PAGES.panel.home", wrap = "crate::CheckLogin")]
async fn panel(data: web::Data<Data>, id: Identity) -> PageResult<impl Responder> {
let sitekeys = get_list_sitekeys(&data, &id).await?;
let body = IndexPage::new(sitekeys).render_once().unwrap();
@ -48,10 +49,7 @@ async fn panel(data: web::Data<Data>, id: Identity) -> PageResult<impl Responder
}
pub fn services(cfg: &mut actix_web::web::ServiceConfig) {
use crate::define_resource;
use crate::PAGES;
define_resource!(cfg, PAGES.panel.home, Methods::ProtectGet, panel);
cfg.service(panel);
sitekey::services(cfg);
}

View file

@ -45,6 +45,7 @@ impl<'a> Default for IndexPage<'a> {
}
}
#[my_codegen::get(path = "crate::PAGES.panel.sitekey.add", wrap = "crate::CheckLogin")]
pub async fn add_sitekey() -> impl Responder {
HttpResponse::Ok()
.content_type("text/html; charset=utf-8")

View file

@ -38,6 +38,7 @@ impl IndexPage {
}
/// render a list of all sitekeys that a user has
#[my_codegen::get(path = "crate::PAGES.panel.sitekey.list", wrap = "crate::CheckLogin")]
pub async fn list_sitekeys(
data: web::Data<Data>,
id: Identity,

View file

@ -38,27 +38,7 @@ pub mod routes {
}
pub fn services(cfg: &mut actix_web::web::ServiceConfig) {
use crate::define_resource;
use crate::PAGES;
define_resource!(
cfg,
PAGES.panel.sitekey.add,
Methods::ProtectGet,
add::add_sitekey
);
define_resource!(
cfg,
PAGES.panel.sitekey.list,
Methods::ProtectGet,
list::list_sitekeys
);
define_resource!(
cfg,
PAGES.panel.sitekey.view,
Methods::ProtectGet,
view::view_sitekey
);
cfg.service(add::add_sitekey);
cfg.service(list::list_sitekeys);
cfg.service(view::view_sitekey);
}

View file

@ -55,6 +55,7 @@ impl IndexPage {
}
/// route handler that renders individual views for sitekeys
#[my_codegen::get(path = "crate::PAGES.panel.sitekey.view", wrap = "crate::CheckLogin")]
pub async fn view_sitekey(
path: web::Path<String>,
data: web::Data<Data>,

View file

@ -25,10 +25,6 @@ pub enum Methods {
ProtectGet,
/// Protected POST handler
ProtectPost,
/// CORS allow all orgin GET handler
CorsAllowAllGet,
/// CORS allow all orgin PST handler
CorsAllowAllPost,
}
/// Defines resoures for [Methods]
@ -67,29 +63,4 @@ macro_rules! define_resource {
.to($to),
);
};
($cfg:expr, $path:expr, Methods::CorsAllowAllGet, $cors:expr, $to:expr) => {
$cfg.service(
actix_web::web::resource($path)
.wrap($cors)
.guard(actix_web::guard::Get())
.to($to),
);
};
($cfg:expr, $path:expr, Methods::CorsAllowAllPost, $to:expr) => {
let cors = Cors::default()
.allow_any_origin()
.allowed_methods(vec!["POST"])
.allow_any_header()
.max_age(0)
.send_wildcard();
$cfg.service(
actix_web::web::resource($path)
.wrap(cors)
.guard(actix_web::guard::Post())
.to($to),
);
};
}