update readme and add travis.yml
diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..6d0ee45 --- /dev/null +++ b/.gitignore
@@ -0,0 +1,2 @@ +.vscode +.DS_Store \ No newline at end of file
diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..7a06679 --- /dev/null +++ b/.travis.yml
@@ -0,0 +1,15 @@ +language: go + +sudo: false + +env: + - GO111MODULE=on + +before_install: + - go get github.com/casbin/casbin + +go: + - "1.14" + +script: + - go test \ No newline at end of file
diff --git a/README b/README deleted file mode 100644 index 4d9cb05..0000000 --- a/README +++ /dev/null
@@ -1,10 +0,0 @@ -Casbin.js Server Utilities for Casbin - -If you are using Casbin.js at your frontend and [Go Casbin](https://github.com/casbin/casbin)as your backend Casbin service, you can install this package at your backend. This package provides a wrapper for generating the user permission, which can be passed to Casbin.js at the frontend. - -### Installation -``` -go get github.com/casbin-js/go-utils/v2 -``` - -
diff --git a/README.md b/README.md new file mode 100644 index 0000000..9d31b30 --- /dev/null +++ b/README.md
@@ -0,0 +1,33 @@ +# Casbin.js Server Utilities for Casbin + +If you are using Casbin.js at your frontend and [Go Casbin](https://github.com/casbin/casbin)as your backend Casbin service, you can install this package at your backend. This package provides a wrapper for generating the user permission, which can be passed to Casbin.js at the frontend. + +### Installation +``` +go get github.com/casbin-js/go-utils/v2 +``` + +### Example +```go +package main + +import ( + "fmt" + + casbinjs "github.com/casbin-js/go-utils" + "github.com/casbin/casbin" +) + +func main() { + e, err := casbin.NewEnforcer("path/to/model.conf", "path/to/policy.csv") + if err != nil { + panic(err) + } + s, _ := casbinjs.GetPermissionForUser(e, "alice") + // Now `s` has the info of alice's permission + // Pass the permission data to your frontend application. +} +``` + + +