示例#1
0
// SetupBuckets adds the given db.Buckets to the DB.
func SetupBuckets(buckets ...[]db.Bucket) SetupFunc {
	return func(t *DB) error {
		for _, bs := range buckets {
			if err := db.SetupBuckets(t, bs); err != nil {
				return err
			}
		}
		return nil
	}
}
示例#2
0
文件: db.go 项目: kamaln7/mf-proto
func SetupBuckets(buckets ...[]db.Bucket) setupFunc {
	return func(t *TestingDB) error {
		for _, bs := range buckets {
			err := db.SetupBuckets(t, bs)
			if err != nil {
				return err
			}
		}
		return nil
	}
}
示例#3
0
func Admin(d db.DB) API {
	return func(r *htr.Router) error {
		if err := db.SetupBuckets(d, admin.Buckets()); err != nil {
			return err
		}
		r.GET("/admin/valid", handleAdminValid(d))
		r.GET("/admin/create", handleAdminCreate(d))
		r.GET("/admin/delete", handleAdminDelete(d))
		return nil
	}
}
示例#4
0
func User(d db.DB) API {
	return func(r *htr.Router) error {
		if err := db.SetupBuckets(d, user.Buckets()); err != nil {
			return err
		}

		r.GET("/user/create", handleUserCreate(d))
		r.GET("/user/delete", handleUserDelete(d))
		r.GET("/user/valid", handleUserValid(d))
		r.GET("/user/login", handleUserLogin(d))
		r.GET("/user/logout", handleUserLogout(d))
		return nil
	}
}
示例#5
0
文件: auth.go 项目: kamaln7/mf-proto
func Auth(d db.DB) API {
	return func(r *htr.Router) error {
		err := db.SetupBuckets(d, auth.Buckets())
		if err != nil {
			return err
		}
		r.GET("/user/create", handleCreate(d))
		r.GET("/user/delete", handleDelete(d))
		r.GET("/user/valid", handleValid(d))
		r.GET("/user/login", handleLogin(d))
		r.GET("/user/logout", handleLogout(d))
		return nil
	}
}
示例#6
0
func AdminCLI(d db.DB) cli.Binding {
	return func(c *cli.CLI) error {
		if err := db.SetupBuckets(d, admin.Buckets()); err != nil {
			return err
		}

		return c.AddCommands(&cli.Command{
			Name:        "create",
			Description: "create a new admin",
			Aliases:     []string{"c", "admin", "new"},
			Fn:          cliCreate(c, d),
		}, &cli.Command{
			Name:        "delete",
			Description: "delete an admin by email",
			Aliases:     []string{"d", "kill"},
			Fn:          cliDelete(d),
		})
	}
}