roles

package
v0.0.0-...-c950848 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 11, 2021 License: GPL-3.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ROLE_SUPERADMIN = 1
	ROLE_ADMIN      = 2
	ROLE_MODERATOR  = 3
	ROLE_EDITOR     = 4
	ROLE_GUEST      = 5
)

Variables

This section is empty.

Functions

func Routes

func Routes(r chi.Router, db *pg.DB) chi.Router

Routes consists of the route method declarations for Roles.

Types

type Handler

type Handler core.Handler

Handler consists of the DB connection and Routes

func (*Handler) Delete

func (cw *Handler) Delete(w http.ResponseWriter, r *http.Request)

Delete handler deletes a role by the provided {roleId}

func (*Handler) Get

func (cw *Handler) Get(w http.ResponseWriter, r *http.Request)

Get handler returns a role by the provided {roleId}

func (*Handler) List

func (cw *Handler) List(w http.ResponseWriter, r *http.Request)

List handler returns all roles in JSON format.

func (*Handler) RoleCtx

func (cw *Handler) RoleCtx(next http.Handler) http.Handler

RoleCtx handler loads a role by either {roleId} or {roleSlug}

func (*Handler) Store

func (cw *Handler) Store(w http.ResponseWriter, r *http.Request)

Store handler creates a new role and returns the role in JSON format.

func (*Handler) Update

func (cw *Handler) Update(w http.ResponseWriter, r *http.Request)

Update handler updates a role by the provided {roleId}

type RoleRequest

type RoleRequest struct {
	*models.Role
}

RoleRequest is a pointer to the Role model.

func (*RoleRequest) Bind

func (t *RoleRequest) Bind(r *http.Request) error

Bind validates the RoleRequest body for required fields.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL