service

package
v0.0.0-...-f441bed Latest Latest
Warning

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

Go to latest
Published: Jan 3, 2016 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Cat

type Cat struct {
	Id      int64  `json:"id,omitempty"`
	Name    string `json:"name,omitempty"`
	CatType string `json:"cat_type,omitempty" gorm:"column:catType"`
}

type Config

type Config struct {
	*config.Server
	MySQL   *config.MySQL
	MongoDB *config.MongoDB
	DB      gorm.DB
	Mongo   *mgo.Database
}

JSONService will implement server.JSONService and handle all requests to the server. Config is a struct to contain all the needed configuration for our JSONService

type Dog

type Dog struct {
	Id   bson.ObjectId `json:"id,omitempty" bson:"_id"`
	Name string        `json:"name,omitempty" bson:"name,omitempty"`
}

type JSONService

type JSONService struct {
	Config *Config
}

func NewJSONService

func NewJSONService(cfg *Config) *JSONService

NewJSONService will instantiate a JSONService with the given configuration.

func (*JSONService) CreateCat

func (s *JSONService) CreateCat(r *http.Request) (int, interface{}, error)

func (*JSONService) DeleteCat

func (s *JSONService) DeleteCat(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.

func (*JSONService) ReadCat

func (s *JSONService) ReadCat(r *http.Request) (int, interface{}, error)

func (*JSONService) ReadCats

func (s *JSONService) ReadCats(r *http.Request) (int, interface{}, error)

func (*JSONService) ReadDogs

func (s *JSONService) ReadDogs(r *http.Request) (int, interface{}, error)

func (*JSONService) UpdateCat

func (s *JSONService) UpdateCat(r *http.Request) (int, interface{}, error)

Jump to

Keyboard shortcuts

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