Documentation
¶
Index ¶
- func CreateDonationHandler(app *App) func(c echo.Context) error
- func CreateDonationRequestHandler(app *App) func(c echo.Context) error
- func FailWith(status int, message string, c echo.Context) error
- func GetDonationWeightByClanHandler(app *App) func(c echo.Context) error
- func GetRequestBody(c echo.Context) ([]byte, error)
- func GetRequestJSON(payloadStruct interface{}, c echo.Context) error
- func GetTX(c echo.Context) newrelic.Transaction
- func HealthCheckHandler(app *App) func(c echo.Context) error
- func LoadJSONPayload(payloadStruct interface{}, c echo.Context, l zap.Logger) error
- func SucceedWith(payload map[string]interface{}, c echo.Context) error
- func UpdateGameHandler(app *App) func(c echo.Context) error
- func UpsertItemHandler(app *App) func(c echo.Context) error
- func ValidatePayload(payload Validatable) []string
- func WithSegment(name string, c echo.Context, f func() error) error
- type App
- type BodyExtractionMiddleware
- type CreateDonationRequestPayload
- type DonationPayload
- type EasyJSONMarshaler
- type EasyJSONUnmarshaler
- type LoggerMiddleware
- type NewRelicMiddleware
- type RecoveryMiddleware
- type SentryMiddleware
- type UpdateGamePayload
- type UpsertItemPayload
- type Validatable
- type Validation
- type VersionMiddleware
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CreateDonationHandler ¶
CreateDonationHandler is the handler responsible for creating donation requests
func CreateDonationRequestHandler ¶
CreateDonationRequestHandler is the handler responsible for creating donation requests
func GetDonationWeightByClanHandler ¶
GetDonationWeightByClanHandler is the handler responsible for creating donation requests
func GetRequestBody ¶
GetRequestBody from echo context
func GetRequestJSON ¶
GetRequestJSON as the specified interface from echo context
func HealthCheckHandler ¶
HealthCheckHandler is the handler responsible for validating that the app is still up
func LoadJSONPayload ¶
LoadJSONPayload loads the JSON payload to the given struct validating all fields are not null
func SucceedWith ¶
SucceedWith sends payload to user with status 200
func UpdateGameHandler ¶
UpdateGameHandler is the handler responsible for updating games
func UpsertItemHandler ¶
UpsertItemHandler is the handler responsible for creating/updating items
func ValidatePayload ¶
func ValidatePayload(payload Validatable) []string
ValidatePayload for any validatable payload
Types ¶
type App ¶
type App struct { Debug bool Port int Host string ConfigPath string App *echo.Echo Engine engine.Server Config *viper.Viper MongoDb *mgo.Database MongoSession *mgo.Session Logger zap.Logger Background bool Fast bool Redsync *redsync.Redsync Redis redis.Conn NewRelic newrelic.Application }
App is a struct that represents a Donations Api APP
func GetApp ¶
func GetApp(host string, port int, configPath string, debug bool, logger zap.Logger, background bool, fast bool) (*App, error)
GetApp returns a new Donations Application
func (*App) OnErrorHandler ¶
OnErrorHandler handles application panics
type BodyExtractionMiddleware ¶
type BodyExtractionMiddleware struct{}
func NewBodyExtractionMiddleware ¶
func NewBodyExtractionMiddleware() *BodyExtractionMiddleware
NewBodyExtractionMiddleware with API version
func (*BodyExtractionMiddleware) Serve ¶
func (v *BodyExtractionMiddleware) Serve(next echo.HandlerFunc) echo.HandlerFunc
Serve serves the middleware
type CreateDonationRequestPayload ¶
type CreateDonationRequestPayload struct { Item string `json:"item"` Player string `json:"player"` Clan string `json:"clan"` }
CreateDonationRequestPayload maps the payload for the Create Game route
func (CreateDonationRequestPayload) MarshalEasyJSON ¶
func (v CreateDonationRequestPayload) MarshalEasyJSON(w *jwriter.Writer)
MarshalEasyJSON supports easyjson.Marshaler interface
func (*CreateDonationRequestPayload) ToJSON ¶
func (cdrp *CreateDonationRequestPayload) ToJSON() ([]byte, error)
ToJSON returns the payload as JSON
func (*CreateDonationRequestPayload) UnmarshalEasyJSON ¶
func (v *CreateDonationRequestPayload) UnmarshalEasyJSON(l *jlexer.Lexer)
UnmarshalEasyJSON supports easyjson.Unmarshaler interface
func (*CreateDonationRequestPayload) Validate ¶
func (cdrp *CreateDonationRequestPayload) Validate() []string
Validate all the required fields for creating a game
type DonationPayload ¶
type DonationPayload struct { Player string `json:"player"` Amount int `json:"amount"` MaxWeightPerPlayer int `json:"maxWeightPerPlayer"` }
DonationPayload maps the payload for the Create Game route
func (DonationPayload) MarshalEasyJSON ¶
func (v DonationPayload) MarshalEasyJSON(w *jwriter.Writer)
MarshalEasyJSON supports easyjson.Marshaler interface
func (*DonationPayload) ToJSON ¶
func (dp *DonationPayload) ToJSON() ([]byte, error)
ToJSON returns the payload as JSON
func (*DonationPayload) UnmarshalEasyJSON ¶
func (v *DonationPayload) UnmarshalEasyJSON(l *jlexer.Lexer)
UnmarshalEasyJSON supports easyjson.Unmarshaler interface
func (*DonationPayload) Validate ¶
func (dp *DonationPayload) Validate() []string
Validate all the required fields for creating a game
type EasyJSONMarshaler ¶
EasyJSONMarshaler describes a struct able to marshal json
type EasyJSONUnmarshaler ¶
EasyJSONUnmarshaler describes a struct able to unmarshal json
type LoggerMiddleware ¶
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 ¶
func (l *LoggerMiddleware) Serve(next echo.HandlerFunc) echo.HandlerFunc
Serve serves the middleware
type NewRelicMiddleware ¶
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 ¶
func (nr *NewRelicMiddleware) Serve(next echo.HandlerFunc) echo.HandlerFunc
Serve serves the middleware
type RecoveryMiddleware ¶
RecoveryMiddleware recovers from errors
func NewRecoveryMiddleware ¶
func NewRecoveryMiddleware(onError func(error, []byte)) *RecoveryMiddleware
NewRecoveryMiddleware returns a configured middleware
func (*RecoveryMiddleware) Serve ¶
func (r *RecoveryMiddleware) Serve(next echo.HandlerFunc) echo.HandlerFunc
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 ¶
func (s *SentryMiddleware) Serve(next echo.HandlerFunc) echo.HandlerFunc
Serve serves the middleware
type UpdateGamePayload ¶
type UpdateGamePayload struct { Name string `json:"name"` DonationCooldownHours int `json:"donationCooldownHours" bson:"donationCooldownHours"` DonationRequestCooldownHours int `json:"donationRequestCooldownHours" bson:"donationRequestCooldownHours"` }
UpdateGamePayload maps the payload for the Create Game route
func (UpdateGamePayload) MarshalEasyJSON ¶
func (v UpdateGamePayload) MarshalEasyJSON(w *jwriter.Writer)
MarshalEasyJSON supports easyjson.Marshaler interface
func (*UpdateGamePayload) ToJSON ¶
func (ugp *UpdateGamePayload) ToJSON() ([]byte, error)
ToJSON returns the payload as JSON
func (*UpdateGamePayload) UnmarshalEasyJSON ¶
func (v *UpdateGamePayload) UnmarshalEasyJSON(l *jlexer.Lexer)
UnmarshalEasyJSON supports easyjson.Unmarshaler interface
func (*UpdateGamePayload) Validate ¶
func (ugp *UpdateGamePayload) Validate() []string
Validate all the required fields for updating a game
type UpsertItemPayload ¶
type UpsertItemPayload struct { Metadata map[string]interface{} `json:"metadata"` WeightPerDonation int `json:"weightPerDonation"` LimitOfItemsPerPlayerDonation int `json:"limitOfItemsPerPlayerDonation"` LimitOfItemsInEachDonationRequest int `json:"limitOfItemsInEachDonationRequest"` }
UpsertItemPayload maps the payload for the Upsert Item route
func (UpsertItemPayload) MarshalEasyJSON ¶
func (v UpsertItemPayload) MarshalEasyJSON(w *jwriter.Writer)
MarshalEasyJSON supports easyjson.Marshaler interface
func (*UpsertItemPayload) ToJSON ¶
func (uip *UpsertItemPayload) ToJSON() ([]byte, error)
ToJSON returns the payload as JSON
func (*UpsertItemPayload) UnmarshalEasyJSON ¶
func (v *UpsertItemPayload) UnmarshalEasyJSON(l *jlexer.Lexer)
UnmarshalEasyJSON supports easyjson.Unmarshaler interface
func (*UpsertItemPayload) Validate ¶
func (uip *UpsertItemPayload) Validate() []string
Validate all the required fields for creating a game
type Validatable ¶
type Validatable interface {
Validate() []string
}
Validatable indicates that a struct can be validated
type Validation ¶
type Validation struct {
// contains filtered or unexported fields
}
Validation struct
func (Validation) MarshalEasyJSON ¶
func (v Validation) MarshalEasyJSON(w *jwriter.Writer)
MarshalEasyJSON supports easyjson.Marshaler interface
func (*Validation) UnmarshalEasyJSON ¶
func (v *Validation) UnmarshalEasyJSON(l *jlexer.Lexer)
UnmarshalEasyJSON supports easyjson.Unmarshaler interface
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 ¶
func (v *VersionMiddleware) Serve(next echo.HandlerFunc) echo.HandlerFunc
Serve serves the middleware