app

package
v2.3.0+incompatible Latest Latest
Warning

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

Go to latest
Published: Jul 12, 2017 License: MIT Imports: 21 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var VERSION = "2.2.1"

VERSION is the current api version

Functions

func GetTX

GetTX returns new relic transaction

func HealthCheckHandler

func HealthCheckHandler(app *App) func(c echo.Context) error

HealthCheckHandler is the handler responsible for validating that the app is still up

func HistoryHandler

func HistoryHandler(app *App) func(c echo.Context) error

HistoryHandler is the handler responsible for sending the rooms history to the player

func HistorySinceHandler

func HistorySinceHandler(app *App) func(c echo.Context) error

HistorySinceHandler is the handler responsible for sending the rooms history to the player based in a initial date

func NotFoundHandler

func NotFoundHandler(app *App) func(c echo.Context) error

NotFoundHandler is the handler responsible for responding when no resource was found

func VersionMiddleware

func VersionMiddleware(next echo.HandlerFunc) echo.HandlerFunc

VersionMiddleware automatically adds a version header to response

func WithSegment

func WithSegment(name string, c echo.Context, f func() error) error

WithSegment adds a segment to new relic transaction

Types

type App

type App struct {
	Debug       bool
	Port        int
	Host        string
	API         *echo.Echo
	Engine      engine.Server
	MQTTBot     *bot.MQTTBot
	RedisClient *redisclient.RedisClient
	NewRelic    newrelic.Application
}

App is the struct that defines the application

func GetApp

func GetApp(host string, port int, debug bool) *App

GetApp creates an app given the parameters

func (*App) Configure

func (app *App) Configure()

Configure configures the application

func (*App) OnErrorHandler

func (app *App) OnErrorHandler(err interface{}, stack []byte)

OnErrorHandler handles application panics

func (*App) Start

func (app *App) Start()

Start starts the application

type LoggerMiddleware

type LoggerMiddleware struct {
	Logger zap.Logger
}

LoggerMiddleware is responsible for logging to Zap all requests

func NewLoggerMiddleware

func NewLoggerMiddleware(theLogger zap.Logger) *LoggerMiddleware

NewLoggerMiddleware returns the logger middleware

func (LoggerMiddleware) Serve

Serve serves the middleware

type Message

type Message struct {
	Timestamp time.Time `json:"timestamp"`
	Payload   string    `json:"payload"`
	Topic     string    `json:"topic"`
}

Message represents a chat message

type NewRelicMiddleware

type NewRelicMiddleware struct {
	App    *App
	Logger zap.Logger
}

NewRelicMiddleware is responsible for logging to Zap all requests

func NewNewRelicMiddleware

func NewNewRelicMiddleware(app *App, theLogger zap.Logger) *NewRelicMiddleware

NewNewRelicMiddleware returns the logger middleware

func (*NewRelicMiddleware) Serve

Serve serves the middleware

type RecoveryMiddleware

type RecoveryMiddleware struct {
	OnError func(interface{}, []byte)
}

RecoveryMiddleware recovers from errors in Echo

func NewRecoveryMiddleware

func NewRecoveryMiddleware(onError func(interface{}, []byte)) *RecoveryMiddleware

NewRecoveryMiddleware returns a configured middleware

func (RecoveryMiddleware) Serve

Serve executes on error handler when errors happen

type SentryMiddleware

type SentryMiddleware struct {
	App *App
}

SentryMiddleware is responsible for sending all exceptions to sentry

func NewSentryMiddleware

func NewSentryMiddleware(app *App) *SentryMiddleware

NewSentryMiddleware returns a new sentry middleware

func (SentryMiddleware) Serve

Serve serves the middleware

Jump to

Keyboard shortcuts

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