api

package
v0.0.0-...-16e9e30 Latest Latest
Warning

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

Go to latest
Published: Aug 22, 2016 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrUnauthorized = errors.New("Unauthorized")
)

Functions

func MakeAddressGetEndpoint

func MakeAddressGetEndpoint(s Service) endpoint.Endpoint

MakeAddressGetEndpoint returns an endpoint via the given service.

func MakeAddressPostEndpoint

func MakeAddressPostEndpoint(s Service) endpoint.Endpoint

MakeAddressPostEndpoint returns an endpoint via the given service.

func MakeCardGetEndpoint

func MakeCardGetEndpoint(s Service) endpoint.Endpoint

MakeUserGetEndpoint returns an endpoint via the given service.

func MakeCardPostEndpoint

func MakeCardPostEndpoint(s Service) endpoint.Endpoint

MakeCardPostEndpoint returns an endpoint via the given service.

func MakeHTTPHandler

func MakeHTTPHandler(ctx context.Context, e Endpoints, logger log.Logger) http.Handler

MakeHTTPHandler mounts the endpoints into a REST-y HTTP handler.

func MakeHealthEndpoint

func MakeHealthEndpoint(s Service) endpoint.Endpoint

MakeHealthEndpoint returns current health of the given service.

func MakeLoginEndpoint

func MakeLoginEndpoint(s Service) endpoint.Endpoint

MakeLoginEndpoint returns an endpoint via the given service.

func MakeRegisterEndpoint

func MakeRegisterEndpoint(s Service) endpoint.Endpoint

MakeRegisterEndpoint returns an endpoint via the given service.

func MakeUserGetEndpoint

func MakeUserGetEndpoint(s Service) endpoint.Endpoint

MakeUserGetEndpoint returns an endpoint via the given service.

func MakeUserPostEndpoint

func MakeUserPostEndpoint(s Service) endpoint.Endpoint

MakeUserPostEndpoint returns an endpoint via the given service.

Types

type EmbedStruct

type EmbedStruct struct {
	Embed interface{} `json:"_embedded"`
}

type Endpoints

type Endpoints struct {
	LoginEndpoint       endpoint.Endpoint
	RegisterEndpoint    endpoint.Endpoint
	UserGetEndpoint     endpoint.Endpoint
	UserPostEndpoint    endpoint.Endpoint
	AddressGetEndpoint  endpoint.Endpoint
	AddressPostEndpoint endpoint.Endpoint
	CardGetEndpoint     endpoint.Endpoint
	CardPostEndpoint    endpoint.Endpoint
	HealthEndpoint      endpoint.Endpoint
}

Endpoints collects the endpoints that comprise the Service.

func MakeEndpoints

func MakeEndpoints(s Service) Endpoints

MakeEndpoints returns an Endpoints structure, where each endpoint is backed by the given service.

type GetRequest

type GetRequest struct {
	ID string
}

type Middleware

type Middleware func(Service) Service

Middleware decorates a service.

func LoggingMiddleware

func LoggingMiddleware(logger log.Logger) Middleware

LoggingMiddleware logs method calls, parameters, results, and elapsed time.

type Service

type Service interface {
	Login(username, password string) (users.User, error) // GET /login
	// Only used for testing at the moment
	Register(username, password, email string) bool
	GetUsers(id string) ([]users.User, error)
	PostUser(u users.User) bool
	GetAddresses(id string) ([]users.Address, error)
	PostAddress(u users.Address, userid string) bool
	GetCards(id string) ([]users.Card, error)
	PostCard(u users.Card, userid string) bool
}

Service is the user service, providing operations for users to login, register, and retrieve customer information.

func NewFixedService

func NewFixedService() Service

NewFixedService returns a simple implementation of the Service interface,

Jump to

Keyboard shortcuts

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