api

package
v3.1.11+incompatible Latest Latest
Warning

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

Go to latest
Published: Nov 3, 2021 License: MIT Imports: 22 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var RecordNotFoundString = "pg: no rows in result set"

RecordNotFoundString is the string returned when a record is not found

View Source
var VERSION = "3.1.11"

VERSION identifies marathon's current version

Functions

func GetTX added in v0.5.0

GetTX returns new relic transaction

func WithSegment added in v0.5.0

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

WithSegment adds a segment to new relic transaction

Types

type AppAuthMiddleware

type AppAuthMiddleware struct {
	App *Application
}

AppAuthMiddleware automatically adds a version header to response

func NewAppAuthMiddleware

func NewAppAuthMiddleware(app *Application) *AppAuthMiddleware

NewAppAuthMiddleware returns a configured auth middleware

func (AppAuthMiddleware) Serve

Serve Validate that a user exists

type Application

type Application struct {
	Debug          bool
	API            *echo.Echo
	Logger         zap.Logger
	Port           int
	Host           string
	DB             interfaces.DB
	PushDB         interfaces.DB
	ConfigPath     string
	Config         *viper.Viper
	NewRelic       newrelic.Application
	Worker         *worker.Worker
	S3Client       interfaces.S3
	SendgridClient *extensions.SendgridClient
}

Application is the api main struct

func GetApplication

func GetApplication(host string, port int, debug bool, l zap.Logger, configPath string) *Application

GetApplication returns a configured api

func (*Application) CreateUserHandler

func (a *Application) CreateUserHandler(c echo.Context) error

CreateUserHandler is the method called when a post to /users is called

func (*Application) DeleteAppHandler

func (a *Application) DeleteAppHandler(c echo.Context) error

DeleteAppHandler is the method called when a delete to /apps/:aid is called

func (*Application) DeleteTemplateHandler added in v0.5.0

func (a *Application) DeleteTemplateHandler(c echo.Context) error

DeleteTemplateHandler is the method called when a delete to /apps/:aid/templates/:tid is called

func (*Application) DeleteUserHandler

func (a *Application) DeleteUserHandler(c echo.Context) error

DeleteUserHandler is the method called when a delete to /users/:id is called

func (*Application) GetAppHandler

func (a *Application) GetAppHandler(c echo.Context) error

GetAppHandler is the method called when a get to /apps/:aid is called

func (*Application) GetJobHandler added in v0.5.0

func (a *Application) GetJobHandler(c echo.Context) error

GetJobHandler is the method called when a get to /apps/:aid/templates/:templateName/jobs/:jid is called

func (*Application) GetTemplateHandler added in v0.5.0

func (a *Application) GetTemplateHandler(c echo.Context) error

GetTemplateHandler is the method called when a get to /apps/:aid/templates/:tid is called

func (*Application) GetUploadURL added in v0.5.0

func (a *Application) GetUploadURL(c echo.Context) error

GetUploadURL handles a file upload

func (*Application) GetUserHandler

func (a *Application) GetUserHandler(c echo.Context) error

GetUserHandler is the method called when a get to /users/:id is called

func (*Application) HealthcheckHandler

func (a *Application) HealthcheckHandler(c echo.Context) error

HealthcheckHandler is the method called when a get to /healthcheck is called

func (*Application) ListAppsHandler added in v0.5.0

func (a *Application) ListAppsHandler(c echo.Context) error

ListAppsHandler is the method called when a get to /apps is called

func (*Application) ListJobsHandler added in v0.5.0

func (a *Application) ListJobsHandler(c echo.Context) error

ListJobsHandler is the method called when a get to /apps/:aid/templates/:templateName/jobs is called

func (*Application) ListTemplatesHandler added in v0.5.0

func (a *Application) ListTemplatesHandler(c echo.Context) error

ListTemplatesHandler is the method called when a get to /apps/:aid/templates is called

func (*Application) ListUsersHandler

func (a *Application) ListUsersHandler(c echo.Context) error

ListUsersHandler is the method called when a get to /users is called

func (*Application) OnErrorHandler

func (a *Application) OnErrorHandler(err error, stack []byte)

OnErrorHandler handles panics

func (*Application) PauseJobHandler added in v0.5.0

func (a *Application) PauseJobHandler(c echo.Context) error

PauseJobHandler is the method called when a put to apps/:id/jobs/:jid/pause is called

func (*Application) PostAppHandler

func (a *Application) PostAppHandler(c echo.Context) error

PostAppHandler is the method called when a post to /apps is called

func (*Application) PostJobHandler added in v0.5.0

func (a *Application) PostJobHandler(c echo.Context) error

PostJobHandler is the method called when a post to /apps/:aid/templates/:templateName/jobs is called

func (*Application) PostTemplateHandler added in v0.5.0

func (a *Application) PostTemplateHandler(c echo.Context) error

PostTemplateHandler is the method called when a post to /apps/:aid/templates is called

func (*Application) PutAppHandler

func (a *Application) PutAppHandler(c echo.Context) error

PutAppHandler is the method called when a put to /apps/:aid is called

func (*Application) PutTemplateHandler added in v0.5.0

func (a *Application) PutTemplateHandler(c echo.Context) error

PutTemplateHandler is the method called when a put to /apps/:aid/templates/:tid is called

func (*Application) ResumeJobHandler added in v0.5.0

func (a *Application) ResumeJobHandler(c echo.Context) error

ResumeJobHandler is the method called when a put to apps/:id/jobs/:jid/resume is called

func (*Application) Start

func (a *Application) Start()

Start starts the api

func (*Application) StopJobHandler added in v0.5.0

func (a *Application) StopJobHandler(c echo.Context) error

StopJobHandler is the method called when a put to apps/:id/jobs/:jid/stop is called

func (*Application) UpdateUserHandler

func (a *Application) UpdateUserHandler(c echo.Context) error

UpdateUserHandler is the method called when a put to /users/:id is called

type Error

type Error struct {
	Reason string          `json:"reason"`
	Value  InputValidation `json:"value"`
}

Error is a struct to help return errors

type Health

type Health struct {
	Healthy bool `json:"healthy"`
}

Health is a struct to help healthcheck handler

type InputValidation

type InputValidation interface {
	Validate(echo.Context) error
}

InputValidation is an interface for all "input submission" structs used for deserialization

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

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

NewRelicMiddleware is responsible for logging to Zap all requests

func NewNewRelicMiddleware

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

NewNewRelicMiddleware returns the logger middleware

func (*NewRelicMiddleware) Serve

Serve serves the middleware

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 {
	Application *Application
}

SentryMiddleware is responsible for sending all exceptions to sentry

func NewSentryMiddleware

func NewSentryMiddleware(app *Application) *SentryMiddleware

NewSentryMiddleware returns a new sentry middleware

func (*SentryMiddleware) Serve

Serve serves the middleware

type UploadAuthMiddleware

type UploadAuthMiddleware struct {
	App *Application
}

UploadAuthMiddleware automatically adds a version header to response

func NewUploadAuthMiddleware

func NewUploadAuthMiddleware(app *Application) *UploadAuthMiddleware

NewUploadAuthMiddleware returns a configured auth middleware

func (UploadAuthMiddleware) Serve

Serve Validate that a user exists

type UserAuthMiddleware

type UserAuthMiddleware struct {
	App *Application
}

UserAuthMiddleware automatically adds a version header to response

func NewUserAuthMiddleware

func NewUserAuthMiddleware(app *Application) *UserAuthMiddleware

NewUserAuthMiddleware returns a configured auth middleware

func (UserAuthMiddleware) Serve

Serve Validate that a user exists

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