Documentation
¶
Index ¶
Constants ¶
const CrudCreateAll string = "CreateAll"
CRUD action constant: Create new item
const CrudCreateOne string = "CreateOne"
CRUD action constant: Create new item
const CrudDeleteAll string = "DeleteAll"
CRUD action constant: Delete all items
const CrudDeleteOne string = "DeleteOne"
CRUD action constant: Delete one item
const CrudReadAll string = "ReadAll"
CRUD action constant: Filter and return all items
const CrudReadOne string = "ReadOne"
CRUD action constant: Find and return one item
const CrudUpdateAll string = "UpdateAll"
CRUD action constant: Update all items
const CrudUpdateOne string = "UpdateOne"
CRUD action constant: Update one item
Variables ¶
var GlobalAllowedOrigins []string
Global allowOrigins to use in all CRUD request (optional)
var GlobalNotAllowHandler webimizer.HttpNotAllowHandler
Global notAllowHandler to use in all CRUD requests if request is not accepted (required)
Functions ¶
func AddCrudHandlers ¶
func AddCrudHandlers(mux *http.ServeMux, one_slug string, all_slug string, permissions_map map[string][]string, crudInterface CrudInterface, authHandler AuthHandler, errorHandler ErrorHandler)
Add CRUD operations handlers to mux *http.ServeMux
Types ¶
type AuthHandler ¶
HttpHandler for user authentication processing and return UserRole if success, otherwise return error
type CrudInterface ¶
type CrudInterface interface { /* Create new item */ CreateOne(rw http.ResponseWriter, r *http.Request, ur *UserRole, uuid *UserUUID) error /* Create new items */ CreateAll(rw http.ResponseWriter, r *http.Request, ur *UserRole, uuid *UserUUID) error /* Find and return one item */ ReadOne(rw http.ResponseWriter, r *http.Request, ur *UserRole, uuid *UserUUID) error /* Filter and return all items */ ReadAll(rw http.ResponseWriter, r *http.Request, ur *UserRole, uuid *UserUUID) error /* Update one item */ UpdateOne(rw http.ResponseWriter, r *http.Request, ur *UserRole, uuid *UserUUID) error /* Update all items */ UpdateAll(rw http.ResponseWriter, r *http.Request, ur *UserRole, uuid *UserUUID) error /* Delete one item */ DeleteOne(rw http.ResponseWriter, r *http.Request, ur *UserRole, uuid *UserUUID) error /* Delete all items */ DeleteAll(rw http.ResponseWriter, r *http.Request, ur *UserRole, uuid *UserUUID) error }
CrudInterface interface for use in CRUD operations by calling Create, ReadOne, ReadAll, Update or Delete func
type UserRole ¶
type UserRole string
UserRole string type, using to give role to user with specific permissions.
There is two constants you can use UserRoleAdmin and UserRoleUser. You can create your own UserRole too.
const UserRoleAdmin UserRole = "Admin"
CRUD UserRole Admin
const UserRoleUser UserRole = "User"
CRUD UserRole User