Documentation ¶
Index ¶
- type Config
- type JSONService
- func (s *JSONService) GetCats(r *http.Request) (int, interface{}, error)
- func (s *JSONService) GetMostPopular(r *http.Request) (int, interface{}, error)
- func (s *JSONService) JSONEndpoints() map[string]map[string]server.JSONEndpoint
- func (s *JSONService) JSONMiddleware(j server.JSONEndpoint) server.JSONEndpoint
- func (s *JSONService) Middleware(h http.Handler) http.Handler
- func (s *JSONService) Prefix() string
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type JSONService ¶
type JSONService struct {
// contains filtered or unexported fields
}
JSONService will implement server.JSONService and handle all requests to the server.
func NewJSONService ¶
func NewJSONService(cfg *Config) *JSONService
NewJSONService will instantiate a JSONService with the given configuration.
func (*JSONService) GetCats ¶
func (s *JSONService) GetCats(r *http.Request) (int, interface{}, error)
func (*JSONService) GetMostPopular ¶
func (s *JSONService) GetMostPopular(r *http.Request) (int, interface{}, error)
func (*JSONService) JSONEndpoints ¶
func (s *JSONService) JSONEndpoints() map[string]map[string]server.JSONEndpoint
JSONEndpoints is a listing of all endpoints available in the JSONService.
func (*JSONService) JSONMiddleware ¶
func (s *JSONService) JSONMiddleware(j server.JSONEndpoint) server.JSONEndpoint
JSONMiddleware provides a JSONEndpoint hook wrapped around all requests. In this implementation, we're using it to provide application logging and to check errors and provide generic responses.
func (*JSONService) Middleware ¶
func (s *JSONService) Middleware(h http.Handler) http.Handler
Middleware provides an http.Handler hook wrapped around all requests. In this implementation, we're using a GzipHandler middleware to compress our responses.
func (*JSONService) Prefix ¶
func (s *JSONService) Prefix() string
Prefix returns the string prefix used for all endpoints within this service.