admin
admin copied to clipboard
Error!
Hi, I'm getting this error when running example on the README!
vendor/github.com/qor/qor/resource/meta.go:111:52: cannot use context.Roles (type []string) as type []interface {} in argument to meta.Permission.HasPermission
vendor/github.com/qor/qor/resource/resource.go:101:51: cannot use context.Roles (type []string) as type []interface {} in argument to res.Permission.HasPermission
^C
my code
package main
import (
"fmt"
"net/http"
"github.com/jinzhu/gorm"
_ "github.com/mattn/go-sqlite3"
"github.com/qor/qor"
"github.com/qor/admin"
)
// Create a GORM-backend model
type User struct {
gorm.Model
Name string
}
// Create another GORM-backend model
type Product struct {
gorm.Model
Name string
Description string
}
func main() {
DB, _ := gorm.Open("sqlite3", "demo.db")
DB.AutoMigrate(&User{}, &Product{})
// Initalize
Admin := admin.New(&admin.AdminConfig{DB: DB})
// Allow to use Admin to manage User, Product
Admin.AddResource(&User{})
Admin.AddResource(&Product{})
// initalize an HTTP request multiplexer
mux := http.NewServeMux()
// Mount admin interface to mux
Admin.MountTo("/admin", mux)
fmt.Println("Listening on: 9000")
http.ListenAndServe(":9000", mux)
}
dublicate to #75