api

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Nov 7, 2016 License: MIT Imports: 21 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddHookHandler

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

AddHookHandler sends new hooks

func FailWith

func FailWith(status int, message string, c echo.Context) error

FailWith fails with the specified message

func GetRequestBody

func GetRequestBody(c echo.Context) (string, error)

GetRequestBody from echo context

func GetRequestJSON

func GetRequestJSON(payloadStruct interface{}, c echo.Context) error

GetRequestJSON as the specified interface from echo context

func GetTX added in v1.0.4

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 StatusHandler

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

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

func WithSegment added in v1.0.4

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 {
	Fast          bool
	Config        *viper.Viper
	Logger        zap.Logger
	ServerOptions *Options
	Engine        engine.Server
	WebApp        *echo.Echo
	Client        *redis.Client
	Queue         string
	Errors        metrics.EWMA
	NewRelic      newrelic.Application
}

App is responsible for Santiago's API

func New

func New(options *Options, logger zap.Logger, fast bool) (*App, error)

New opens a new channel connection

func (*App) GetMessageCount

func (a *App) GetMessageCount() (int, error)

GetMessageCount returns the message count for the queue

func (*App) PublishHook

func (a *App) PublishHook(method, url string, payload string) error

PublishHook sends a hook to the queue

func (*App) Start

func (a *App) Start()

Start 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 NewRelicMiddleware added in v1.0.4

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

NewRelicMiddleware is responsible for logging to Zap all requests

func NewNewRelicMiddleware added in v1.0.4

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

NewNewRelicMiddleware returns the logger middleware

func (*NewRelicMiddleware) Serve added in v1.0.4

Serve serves the middleware

type Options

type Options struct {
	Host       string
	Port       int
	Debug      bool
	ConfigFile string
}

Options specify configuration to start api with

func DefaultOptions

func DefaultOptions() *Options

DefaultOptions returns local development options for api

func NewOptions

func NewOptions(host string, port int, debug bool, configFile string) *Options

NewOptions returns new options to create API

type RecoveryMiddleware

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

RecoveryMiddleware recovers from errors

func NewRecoveryMiddleware

func NewRecoveryMiddleware(onError func(error, []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

type VersionMiddleware

type VersionMiddleware struct {
	Version string
}

VersionMiddleware inserts the current version in all requests

func NewVersionMiddleware

func NewVersionMiddleware() *VersionMiddleware

NewVersionMiddleware with API version

func (*VersionMiddleware) Serve

Serve serves the middleware

Jump to

Keyboard shortcuts

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