handlers

package
v0.0.0-...-8341997 Latest Latest
Warning

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

Go to latest
Published: Apr 26, 2017 License: MIT Imports: 15 Imported by: 3

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetCors

func GetCors() gin.HandlerFunc

GetCors returns a gin handlerFunc for CORS reuquests in expresso services

Types

type BaseHandler

type BaseHandler struct {
	Stats *statsd.Client
}

BaseHandler contains wrapper methods that all handlers need and should use

for consistency across services

func NewBaseHandler

func NewBaseHandler(stats *statsd.Client) *BaseHandler

NewBaseHandler returns a new BaseHandler instance from a given stats

func (*BaseHandler) GetJWT

func (b *BaseHandler) GetJWT() gin.HandlerFunc

GetJWT returns a gin handlerfunc for authenticating JWTs in expresso services

func (*BaseHandler) GetPaging

func (b *BaseHandler) GetPaging(ctx *gin.Context) (int, int)

GetPaging returns the offset and limit parameters from a gin request context defaults to offset=0 and limit=20

func (*BaseHandler) NotFoundError

func (b *BaseHandler) NotFoundError(ctx *gin.Context, msg string)

NotFoundError sends a 404 response and false success when a resource is not present

func (*BaseHandler) ServerError

func (b *BaseHandler) ServerError(ctx *gin.Context, err error, obj interface{})

ServerError sends a 500 response with the given error and object

func (*BaseHandler) Success

func (b *BaseHandler) Success(ctx *gin.Context, obj interface{})

Success sends a 200 response with the given object

func (*BaseHandler) Time

func (b *BaseHandler) Time() gin.HandlerFunc

Time sets up gin middleware for sending timing stats

func (*BaseHandler) Unauthorized

func (b *BaseHandler) Unauthorized(ctx *gin.Context, msg string)

Unauthorized sends a 401 response along with a message

func (*BaseHandler) UserError

func (b *BaseHandler) UserError(ctx *gin.Context, msg string, obj interface{})

UserError sends a 400 response with the given message string and error object

type Content

type Content struct {
	*BaseHandler
	Content helpers.ContentI
}

Content is the handler for all content api calls

func (*Content) Deactivate

func (c *Content) Deactivate(ctx *gin.Context)

Deactivate sets a content's status to INACTIVE

func (*Content) New

func (c *Content) New(ctx *gin.Context)

New adds the given content entry to the database

func (*Content) Update

func (c *Content) Update(ctx *gin.Context)

Update overwrites content data for the content with the given id

func (*Content) View

func (c *Content) View(ctx *gin.Context)

View returns a content described by the given id

func (*Content) ViewAll

func (c *Content) ViewAll(ctx *gin.Context)

ViewAll returns a list of content with limit and offset

determining the entries and amount (default 0,20)

type ContentI

type ContentI interface {
	New(ctx *gin.Context)
	ViewAll(ctx *gin.Context)
	View(ctx *gin.Context)
	Update(ctx *gin.Context)
	Deactivate(ctx *gin.Context)
	Time() gin.HandlerFunc
	GetJWT() gin.HandlerFunc
}

ContentI has the methods for a content handler

func NewContent

func NewContent(ctx *GatewayContext) ContentI

NewContent returns a content handler

type ExpressoClaims

type ExpressoClaims struct {
	UserID string `json:"userId"`
	jwt.StandardClaims
}

type GatewayContext

type GatewayContext struct {
	Sql        gateways.SQL
	Sendgrid   gateways.SendgridI
	TownCenter t.TownCenterI
	Covenant   cov.Covenant
	Warehouse  w.Warehouse
	Bloodlines gateways.Bloodlines
	Coinage    coi.Coinage
	Rabbit     gateways.RabbitI
	Stats      *statsd.Client
	Stripe     coi.Stripe
	S3         gateways.S3
	Shippo     w.Shippo
}

GatewayContext contains references to each type of gateway used for simple

use in handler construction

type Job

type Job struct {
	*BaseHandler
	Helper helpers.JobI
}

Job is the implementation with Helper of JobI

func NewJob

func NewJob(ctx *GatewayContext) *Job

NewJob constructs a new Job handler

func (*Job) New

func (j *Job) New(ctx *gin.Context)

New creates and inserts a new job entity

func (*Job) Stop

func (j *Job) Stop(ctx *gin.Context)

Stop sets a job's status to Failure. Only used if the job hasn't started

func (*Job) Update

func (j *Job) Update(ctx *gin.Context)

Update is not implemented

func (*Job) View

func (j *Job) View(ctx *gin.Context)

View returns one job with the given id

func (*Job) ViewAll

func (j *Job) ViewAll(ctx *gin.Context)

ViewAll returns a list of jobs from offset and limit params (default 0,20)

type JobI

type JobI interface {
	New(ctx *gin.Context)
	ViewAll(ctx *gin.Context)
	View(ctx *gin.Context)
	Update(ctx *gin.Context)
	Stop(ctx *gin.Context)
	Time() gin.HandlerFunc
	GetJWT() gin.HandlerFunc
}

JobI is the interface for job endpoints

type Preference

type Preference struct {
	*BaseHandler
	Helper helpers.PreferenceI
}

Preference implements PreferenceI for handling requests

func NewPreference

func NewPreference(ctx *GatewayContext) *Preference

NewPreference constructs and returns a new preference handler

func (*Preference) Deactivate

func (p *Preference) Deactivate(ctx *gin.Context)

Deactivate sets a user's preference entity to UNSUBSCRIBED

func (*Preference) New

func (p *Preference) New(ctx *gin.Context)

New creates and stores a new preference entry based on the given preference struct

func (*Preference) Update

func (p *Preference) Update(ctx *gin.Context)

Update overwrites a preference entity associated with the given user id

func (*Preference) View

func (p *Preference) View(ctx *gin.Context)

View returns a preference entity associated with the given user id

type PreferenceI

type PreferenceI interface {
	New(ctx *gin.Context)
	View(ctx *gin.Context)
	Update(ctx *gin.Context)
	Deactivate(ctx *gin.Context)
	Time() gin.HandlerFunc
	GetJWT() gin.HandlerFunc
}

PreferenceI describes the handler for preferences routes

type Receipt

type Receipt struct {
	*BaseHandler
	Helper  helpers.ReceiptI
	CHelper helpers.ContentI
}

Receipt implements ReceiptI for the receipt router

func NewReceipt

func NewReceipt(ctx *GatewayContext) *Receipt

NewReceipt constructs and returns a new receipt handler

func (*Receipt) Send

func (r *Receipt) Send(ctx *gin.Context)

Send creates a message based on the receipt provided

func (*Receipt) View

func (r *Receipt) View(ctx *gin.Context)

View returns the receipt with the given id

func (*Receipt) ViewAll

func (r *Receipt) ViewAll(ctx *gin.Context)

ViewAll returns a list of Receipt entities starting at offset up to limit

type ReceiptI

type ReceiptI interface {
	Send(ctx *gin.Context)
	ViewAll(ctx *gin.Context)
	View(ctx *gin.Context)
	Time() gin.HandlerFunc
	GetJWT() gin.HandlerFunc
}

ReceiptI describes the Receipt interface interactions

type Trigger

type Trigger struct {
	*BaseHandler
	Trigger helpers.TriggerI
	Receipt helpers.ReceiptI
	Content helpers.ContentI
}

Trigger implements TriggerI and uses a trigger helper

func NewTrigger

func NewTrigger(ctx *GatewayContext) *Trigger

NewTrigger constructs and returns reference to a Trigger handler

func (*Trigger) Activate

func (t *Trigger) Activate(ctx *gin.Context)

Activate starts a trigger's action

func (*Trigger) New

func (t *Trigger) New(ctx *gin.Context)

New creates a new trigger entity based on the given data

func (*Trigger) Remove

func (t *Trigger) Remove(ctx *gin.Context)

Remove sets a trigger to inactive

func (*Trigger) Update

func (t *Trigger) Update(ctx *gin.Context)

Update overwrites the trigger entity with new values provided

func (*Trigger) View

func (t *Trigger) View(ctx *gin.Context)

View returns a trigger with id provided

func (*Trigger) ViewAll

func (t *Trigger) ViewAll(ctx *gin.Context)

ViewAll returns a list of trigger entites based on the offset and limit (default 0, 20)

type TriggerI

type TriggerI interface {
	New(ctx *gin.Context)
	ViewAll(ctx *gin.Context)
	View(ctx *gin.Context)
	Update(ctx *gin.Context)
	Remove(ctx *gin.Context)
	Activate(ctx *gin.Context)
	Time() gin.HandlerFunc
	GetJWT() gin.HandlerFunc
}

TriggerI describes the methods for a Trigger handler

Jump to

Keyboard shortcuts

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