1
0
mirror of https://github.com/actix/examples synced 2024-11-30 17:14:35 +01:00

Update dependencies for casbin example. (#300)

* Update dependencies & Clean description.

* Add .env for logger.

* Updating code due to code review.
This commit is contained in:
Chojan Shang 2020-04-20 06:52:00 +08:00 committed by GitHub
parent 3b7d9d8b7a
commit 9155edfe8d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 5 additions and 9 deletions

View File

@ -7,6 +7,6 @@ workspace = ".."
[dependencies]
actix-web = "2.0"
actix-rt = "1.0"
casbin = "0.4"
actix-rt = "1.1.0"
casbin = "0.6.0"
loge = {version = "0.4", default-features = false, features = ["colored", "chrono"]}

View File

@ -23,5 +23,4 @@ In this example, you can get the the successful result at `http://localhost:8080
## Others
- Original location of this demo: <https://github.com/PsiACE/actix-casbin-example>
- For more related examples of [Casbin-RS](https://github.com/casbin/casbin-rs): <https://github.com/casbin-rs/examples>

View File

@ -1,5 +1,4 @@
use casbin::{DefaultModel, Enforcer, FileAdapter, RbacApi};
use std::boxed::Box;
use casbin::{CoreApi, DefaultModel, Enforcer, FileAdapter, RbacApi};
use std::io;
use std::sync::RwLock;
@ -37,9 +36,7 @@ async fn main() -> io::Result<()> {
.unwrap();
let adapter = FileAdapter::new("rbac/rbac_policy.csv");
let e = Enforcer::new(Box::new(model), Box::new(adapter))
.await
.unwrap();
let e = Enforcer::new(model, adapter).await.unwrap();
let e = web::Data::new(RwLock::new(e)); // wrap enforcer into actix-state
//move is necessary to give closure below ownership of counter