1
0
mirror of https://github.com/kataras/iris.git synced 2025-12-20 03:17:04 +00:00

remove experimental-handlers examples, users should visit github.com/iris-contrib/middleware instead, let's not have duplications

Former-commit-id: 72754683d1bcd4325b5fcd9f57c6cb87f1d7337d
This commit is contained in:
Gerasimos (Makis) Maropoulos
2019-07-15 16:03:19 +03:00
parent 5b4cc9a0a2
commit 55bdb44e26
22 changed files with 12 additions and 658 deletions

View File

@@ -1,43 +0,0 @@
package main
import (
"github.com/kataras/iris"
"github.com/casbin/casbin"
cm "github.com/iris-contrib/middleware/casbin"
)
// $ go get github.com/casbin/casbin
// $ go run main.go
// Enforcer maps the model and the policy for the casbin service, we use this variable on the main_test too.
var Enforcer = casbin.NewEnforcer("casbinmodel.conf", "casbinpolicy.csv")
func newApp() *iris.Application {
casbinMiddleware := cm.New(Enforcer)
app := iris.New()
app.WrapRouter(casbinMiddleware.Wrapper())
app.Get("/", hi)
app.Any("/dataset1/{p:path}", hi) // p, dataset1_admin, /dataset1/*, * && p, alice, /dataset1/*, GET
app.Post("/dataset1/resource1", hi)
app.Get("/dataset2/resource2", hi)
app.Post("/dataset2/folder1/{p:path}", hi)
app.Any("/dataset2/resource1", hi)
return app
}
func main() {
app := newApp()
app.Run(iris.Addr(":8080"))
}
func hi(ctx iris.Context) {
ctx.Writef("Hello %s", cm.Username(ctx.Request()))
}