From c394f8159e9029c5b071a5e7366f2a0ef5b4a6e5 Mon Sep 17 00:00:00 2001 From: anonymous Date: Sun, 25 Oct 2020 22:57:37 +0700 Subject: [PATCH] remove example --- README.md | 2 +- example/main.go | 48 ---------------------------------------------- example/model.conf | 11 ----------- 3 files changed, 1 insertion(+), 60 deletions(-) delete mode 100644 example/main.go delete mode 100644 example/model.conf diff --git a/README.md b/README.md index 4ad3443..21cd831 100644 --- a/README.md +++ b/README.md @@ -16,7 +16,7 @@ go get github.com/prongbang/fiber-casbinrest - model.conf -``` +```editorconfig [request_definition] r = sub, obj, act diff --git a/example/main.go b/example/main.go deleted file mode 100644 index 8dab099..0000000 --- a/example/main.go +++ /dev/null @@ -1,48 +0,0 @@ -package main - -import ( - "log" - - "github.com/casbin/casbin/v2" - mongodbadapter "github.com/casbin/mongodb-adapter/v3" - "github.com/gofiber/fiber/v2" - fibercasbinrest "github.com/prongbang/fiber-casbinrest" -) - -func main() { - a, _ := mongodbadapter.NewAdapter("127.0.0.1:27017") - - e, _ := casbin.NewEnforcer("example/model.conf", a) - - // Modify the policy. - _, _ = e.AddPolicy("anonymous", "/login", "GET") - _, _ = e.AddPolicy("admin", "/admin", "(GET)|(POST)") - _, _ = e.AddPolicy("admin", "/admin/user/:id", "GET") - _, _ = e.AddPolicy("admin", "/manage/*", "GET") - //e.RemovePolicy(...) - - // Save the policy back to DB. - _ = e.SavePolicy() - - // Load the policy from DB. - _ = e.LoadPolicy() - - app := fiber.New() - app.Use(fibercasbinrest.NewDefault(e, "secret")) - - app.Post("/admin", func(c *fiber.Ctx) error { - return c.SendString("Hello, World 👋!") - }) - app.Get("/admin/user/:id", func(c *fiber.Ctx) error { - return c.SendString("Hello, User 👋!") - }) - app.Get("/manage/:id", func(c *fiber.Ctx) error { - return c.SendString("Hello, Manage 👋!") - }) - - app.Get("/login", func(c *fiber.Ctx) error { - return c.SendString("Hello, login 👋!") - }) - - log.Fatal(app.Listen(":3000")) -} diff --git a/example/model.conf b/example/model.conf deleted file mode 100644 index 38690d3..0000000 --- a/example/model.conf +++ /dev/null @@ -1,11 +0,0 @@ -[request_definition] -r = sub, obj, act - -[policy_definition] -p = sub, obj, act - -[policy_effect] -e = some(where (p.eft == allow)) - -[matchers] -m = r.sub == p.sub && (keyMatch(r.obj, p.obj) || keyMatch2(r.obj, p.obj)) && (r.act == p.act || regexMatch(r.act, p.act)) \ No newline at end of file