Documentation
¶
Index ¶
- Variables
- func NewOrganization(organization Organization, repo Repository) func(handler http.Handler) http.Handler
- type CassandraRepository
- func (r *CassandraRepository) Add(organization *Organization) error
- func (r *CassandraRepository) AddOrganization(organization *OrganizationConfig) error
- func (r *CassandraRepository) FindAll() ([]*Organization, error)
- func (r *CassandraRepository) FindByUsername(username string) (*Organization, error)
- func (r *CassandraRepository) FindOrganization(organization string) (*OrganizationConfig, error)
- func (r *CassandraRepository) Remove(username string) error
- type Handler
- func (c *Handler) Create() http.HandlerFunc
- func (c *Handler) CreateOrganization() http.HandlerFunc
- func (c *Handler) Delete() http.HandlerFunc
- func (c *Handler) Index() http.HandlerFunc
- func (c *Handler) Show() http.HandlerFunc
- func (c *Handler) ShowOrganization() http.HandlerFunc
- func (c *Handler) Update() http.HandlerFunc
- func (c *Handler) UpdateOrganization() http.HandlerFunc
- type Organization
- type OrganizationConfig
- type OrganizationUserAndConfig
- type Repository
Constants ¶
This section is empty.
Variables ¶
var ( // ErrNotAuthorized is used when the the access is not permisted ErrNotAuthorized = errors.New(http.StatusUnauthorized, "not authorized") // ErrUserNotFound is used when an user is not found ErrUserNotFound = errors.New(http.StatusNotFound, "user not found") // ErrUserExists is used when an user already exists ErrUserExists = errors.New(http.StatusNotFound, "user already exists") // ErrInvalidAdminRouter is used when an invalid admin router is given ErrInvalidAdminRouter = errors.New(http.StatusNotFound, "invalid admin router given") )
Functions ¶
func NewOrganization ¶
func NewOrganization(organization Organization, repo Repository) func(handler http.Handler) http.Handler
NewOrganization is a HTTP organization middleware
Types ¶
type CassandraRepository ¶
type CassandraRepository struct {
// contains filtered or unexported fields
}
CassandraRepository represents a cassandra repository
func NewCassandraRepository ¶
func NewCassandraRepository(session wrapper.Holder) (*CassandraRepository, error)
func (*CassandraRepository) Add ¶
func (r *CassandraRepository) Add(organization *Organization) error
Add adds an user to the repository
func (*CassandraRepository) AddOrganization ¶
func (r *CassandraRepository) AddOrganization(organization *OrganizationConfig) error
AddOrganization adds an organization to the repository
func (*CassandraRepository) FindAll ¶
func (r *CassandraRepository) FindAll() ([]*Organization, error)
FindAll fetches all the basic user definitions available
func (*CassandraRepository) FindByUsername ¶
func (r *CassandraRepository) FindByUsername(username string) (*Organization, error)
FindByUsername find an user by username returns ErrUserNotFound when a user is not found.
func (*CassandraRepository) FindOrganization ¶
func (r *CassandraRepository) FindOrganization(organization string) (*OrganizationConfig, error)
FindByUsername find an user by username returns ErrUserNotFound when a user is not found.
func (*CassandraRepository) Remove ¶
func (r *CassandraRepository) Remove(username string) error
Remove an user from the repository
type Handler ¶
type Handler struct {
// contains filtered or unexported fields
}
Handler is the api rest handlers
func NewHandler ¶
func NewHandler(repo Repository) *Handler
NewHandler creates a new instance of Handler
func (*Handler) CreateOrganization ¶
func (c *Handler) CreateOrganization() http.HandlerFunc
CreateOrganization is the create organization handler
func (*Handler) ShowOrganization ¶
func (c *Handler) ShowOrganization() http.HandlerFunc
ShowOrganization is the find by handler
func (*Handler) UpdateOrganization ¶
func (c *Handler) UpdateOrganization() http.HandlerFunc
UpdateOrganization is the update handler
type Organization ¶
type Organization struct { Username string `json:"username"` Organization string `json:"organization"` Password string `json:"password"` }
Organization represents the configuration to save the user and organization pair
type OrganizationConfig ¶
type OrganizationConfig struct { Organization string `json:"organization"` Priority int `json:"priority"` ContentPerDay int `json:"contentPerDay"` Config map[string]interface{} `json:"config"` }
OrganizationConfig represents the configuration to save the user and organization pair
type Repository ¶
type Repository interface { FindAll() ([]*Organization, error) FindByUsername(username string) (*Organization, error) FindOrganization(organization string) (*OrganizationConfig, error) Add(organization *Organization) error AddOrganization(organization *OrganizationConfig) error Remove(username string) error }
Repository represents an user repository