handlers

package
v0.0.0-...-6dea0d5 Latest Latest
Warning

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

Go to latest
Published: Dec 22, 2018 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CommonHandler

type CommonHandler struct {
	Storage     storage.Storager
	Logger      zerolog.Logger
	Marshaler   func(v interface{}) ([]byte, error)
	Unmarshaler func(data []byte, v interface{}) error
}

CommonHandler strucute for basic dependencies for rest handlers

func (*CommonHandler) Marshal

func (ch *CommonHandler) Marshal(v interface{}) ([]byte, error)

Marshal will marshal the provided value with the Marshaller defined on ch. If un-set, json.Marshal will be used.

func (*CommonHandler) SetLogger

func (ch *CommonHandler) SetLogger(logger zerolog.Logger)

SetLogger sets logger

func (*CommonHandler) SetStorage

func (ch *CommonHandler) SetStorage(st storage.Storager)

SetStorage sets storage

func (*CommonHandler) Unmarshal

func (ch *CommonHandler) Unmarshal(data []byte, v interface{}) error

Unmarshal will unmarshal the provided value with the Unmarshaler defined on ch. If un-set, json.Unmarshal will be used.

type HeroHandler

type HeroHandler struct {
	CommonHandler
}

HeroHandler contains hero handler data extend common handler

func (*HeroHandler) CreateHeroHandler

func (hh *HeroHandler) CreateHeroHandler(w http.ResponseWriter, r *http.Request)

CreateHeroHandler handler to create a new hero

func (*HeroHandler) DeleteHeroHandler

func (hh *HeroHandler) DeleteHeroHandler(w http.ResponseWriter, r *http.Request)

DeleteHeroHandler handler to delete hero

func (*HeroHandler) GetHeroHandler

func (hh *HeroHandler) GetHeroHandler(w http.ResponseWriter, r *http.Request)

GetHeroHandler handler to get single hero

func (*HeroHandler) GetHeroesHandler

func (hh *HeroHandler) GetHeroesHandler(w http.ResponseWriter, r *http.Request)

GetHeroesHandler handler to get all heroes

type StatusHandler

type StatusHandler struct {
	CommonHandler
}

StatusHandler contains status handler data extend common handler

func (*StatusHandler) GetStatusHandler

func (sh *StatusHandler) GetStatusHandler(w http.ResponseWriter, _ *http.Request)

GetStatusHandler handle for application status endpoint

type StatusResponse

type StatusResponse struct {
	Redis string `json:"redis"`
}

StatusResponse displays status of required app dependencies (e.g. storage)

Jump to

Keyboard shortcuts

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