Skip to content

Casbin Auth Middleware's sample code has compilation error #129

@MasatoshiTada

Description

@MasatoshiTada

The code below has a compilation error:

e := echo.New()
e.Use(casbin_mw.Middleware(casbin.NewEnforcer("casbin_auth_model.conf", "casbin_auth_policy.csv")))
$ go build src/server.go 
# command-line-arguments
src/server.go:46:27: too many arguments in call to "github.com/labstack/echo-contrib/casbin".Middleware
        have (*"github.com/casbin/casbin".Enforcer, error)
        want (*"github.com/casbin/casbin".Enforcer)

We have to change this code like this:

e := echo.New()
enforcer, err := casbin.NewEnforcer("casbin_auth_model.conf", "casbin_auth_policy.csv")
e.Use(casbin_mw.Middleware(enforcer))

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions