controllers

package
v0.0.0-...-459856e Latest Latest
Warning

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

Go to latest
Published: Jan 8, 2020 License: BSD-2-Clause Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetRoot

func GetRoot(c *gin.Context)

GetRoot handles requests to the root url

Types

type ErrorBody

type ErrorBody struct {
	EveryBody
	Error ErrorDetails `json:"error"`
}

ErrorBody is the body that is returned on errors

func ErrorResponse

func ErrorResponse(action, errorType string, err error) ErrorBody

ErrorResponse returns a map that can be given as an argument to c.JSON

type ErrorDetails

type ErrorDetails struct {
	Type    string `json:"type"`
	Message string `json:"message"`
}

ErrorDetails are details about errors

type EventAPI

type EventAPI interface {
	RESTAPI
}

EventAPI is the interface for the Event REST methods

func NewEventAPI

func NewEventAPI(repo datastore.EventRepo) EventAPI

NewEventAPI takes an ORM and returns an NewEventHandle

type EventHandle

type EventHandle struct {
	Repo datastore.EventRepo
}

EventHandle contains the orm layer for User objects

func (*EventHandle) Create

func (e *EventHandle) Create(c *gin.Context)

Create creates an Event

func (*EventHandle) Delete

func (e *EventHandle) Delete(c *gin.Context)

Delete deletes an event and returns the object

func (*EventHandle) GetAll

func (e *EventHandle) GetAll(c *gin.Context)

GetAll gets all events

func (*EventHandle) GetByID

func (e *EventHandle) GetByID(c *gin.Context)

GetByID gets an event by its ID

func (*EventHandle) Update

func (e *EventHandle) Update(c *gin.Context)

Update updates an Event and returns it

type EveryBody

type EveryBody struct {
	Action string `json:"action"`
	Status string `json:"status"`
}

EveryBody is the body that is always returned

type RESTAPI

type RESTAPI interface {
	GetAll(c *gin.Context)
	GetByID(c *gin.Context)
	Create(c *gin.Context)
	Update(c *gin.Context)
	Delete(c *gin.Context)
}

RESTAPI is an interface for implementation by REST controllers

type SuccessBody

type SuccessBody struct {
	EveryBody
	Result interface{} `json:"result"`
}

SuccessBody is the body that is returned on success

func SuccessResponse

func SuccessResponse(action string, result interface{}) SuccessBody

SuccessResponse returns a map that can be given as an argument to c.JSON

type UserAPI

type UserAPI interface {
	RESTAPI

	//additional methods
	GetByAlias(c *gin.Context)
}

UserAPI is the interface for the user API

func NewUserAPI

func NewUserAPI(repo datastore.UserRepo) UserAPI

NewUserAPI takes an ORM and returns a RESTAPI

type UserHandle

type UserHandle struct {
	Repo datastore.UserRepo
}

UserHandle is a handle for the user API

func (*UserHandle) Create

func (u *UserHandle) Create(c *gin.Context)

Create adds a user and returns it

func (*UserHandle) Delete

func (u *UserHandle) Delete(c *gin.Context)

Delete deletes a user

func (*UserHandle) GetAll

func (u *UserHandle) GetAll(c *gin.Context)

GetAll returns an array of all users

func (*UserHandle) GetByAlias

func (u *UserHandle) GetByAlias(c *gin.Context)

GetByAlias returns a user with a certain alias

func (*UserHandle) GetByID

func (u *UserHandle) GetByID(c *gin.Context)

GetByID returns a user with a certain id

func (*UserHandle) Update

func (u *UserHandle) Update(c *gin.Context)

Update updates the properties of a user

Jump to

Keyboard shortcuts

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