playersvc

package module
v0.0.0-...-582566e Latest Latest
Warning

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

Go to latest
Published: Oct 22, 2022 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrMissingIds = errors.New("missing ids")
	ErrParsingIds = errors.New("error parsing ids, should be ints")
)
View Source
var (
	ErrPlayerDoesNotExist = errors.New("player does not exist")
)

Functions

func MakeAddEndpoint

func MakeAddEndpoint(svc Service) endpoint.Endpoint

func MakeGetAllEndpoint

func MakeGetAllEndpoint(svc Service) endpoint.Endpoint

func MakeHTTPHandler

func MakeHTTPHandler(e EndpointSet, logger log.Logger) http.Handler

func MakeUpdateEndpoint

func MakeUpdateEndpoint(svc Service) endpoint.Endpoint

Types

type EndpointSet

type EndpointSet struct {
	GetAllEndpoint endpoint.Endpoint
	AddEndpoint    endpoint.Endpoint
	UpdateEndpoint endpoint.Endpoint
}

func MakeClientEndpoints

func MakeClientEndpoints(instance string) (EndpointSet, error)

func MakeServerEndpoints

func MakeServerEndpoints(svc Service) EndpointSet

func (*EndpointSet) Add

func (e *EndpointSet) Add(ctx context.Context, name string) (Player, error)

func (*EndpointSet) GetAll

func (e *EndpointSet) GetAll(ctx context.Context) ([]Player, error)

func (*EndpointSet) Increment

func (e *EndpointSet) Increment(ctx context.Context, player Player) (Player, error)

type Player

type Player struct {
	Id   int    `json:"id"`
	Name string `json:"name"`
}

func (Player) String

func (t Player) String() string

type Service

type Service interface {
	Add(ctx context.Context, name string) (Player, error)
	GetAll(ctx context.Context) ([]Player, error)
	Update(ctx context.Context, player Player) (Player, error)
}

func NewService

func NewService(logger log.Logger) Service

type ServiceMiddleware

type ServiceMiddleware func(Service) Service

func LoggingMiddleware

func LoggingMiddleware(logger log.Logger) ServiceMiddleware

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

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