Documentation ¶
Index ¶
- Variables
- func MakeAuthoriseEndpoint(s Service) endpoint.Endpoint
- func MakeHTTPHandler(ctx context.Context, e Endpoints, logger log.Logger) http.Handler
- func MakeHealthEndpoint(s Service) endpoint.Endpoint
- func WireUp(ctx context.Context, declineAmount float32) (http.Handler, log.Logger)
- type Authorisation
- type AuthoriseRequest
- type AuthoriseResponse
- type Endpoints
- type Middleware
- type Service
- type UnmarshalKeyError
Constants ¶
This section is empty.
Variables ¶
var ErrInvalidJson = errors.New("Invalid json")
var ErrInvalidPaymentAmount = errors.New("Invalid payment amount")
Functions ¶
func MakeAuthoriseEndpoint ¶
MakeListEndpoint returns an endpoint via the given service.
func MakeHTTPHandler ¶
MakeHTTPHandler mounts the endpoints into a REST-y HTTP handler.
func MakeHealthEndpoint ¶
MakeHealthEndpoint returns current health of the given service.
Types ¶
type Authorisation ¶
type Authorisation struct {
Authorised bool `json:"authorised"`
}
type AuthoriseRequest ¶
type AuthoriseRequest struct {
Amount float32 `json:"amount"`
}
AuthoriseRequest represents a request for payment authorisation. The Amount is the total amount of the transaction
type AuthoriseResponse ¶
type AuthoriseResponse struct { Authorisation Authorisation Err error }
AuthoriseResponse returns a response of type Authorisation and an error, Err.
type Endpoints ¶
Endpoints collects the endpoints that comprise the Service.
func MakeEndpoints ¶
MakeEndpoints returns an Endpoints structure, where each endpoint is backed by the given service.
type Middleware ¶
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 {
Authorise(total float32) (Authorisation, error) // GET /paymentAuth
}
func NewAuthorisationService ¶
NewFixedService returns a simple implementation of the Service interface, fixed over a predefined set of socks and tags. In a real service you'd probably construct this with a database handle to your socks DB, etc.
type UnmarshalKeyError ¶
func (*UnmarshalKeyError) Error ¶
func (e *UnmarshalKeyError) Error() string