profilesvc

package
v0.0.0-...-d0adc60 Latest Latest
Warning

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

Go to latest
Published: Mar 14, 2024 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrInconsistentIDs = errors.New("inconsistent IDs")
	ErrAlreadyExists   = errors.New("already exists")
	ErrNotFound        = errors.New("not found")
)
View Source
var (
	ErrBadRouting = errors.New("inconsistent mapping between route and handler (programmer error)")
)

Functions

func MakeDeleteAddressEndpoint

func MakeDeleteAddressEndpoint(s Service) endpoint.Endpoint

func MakeDeleteProfileEndpoint

func MakeDeleteProfileEndpoint(s Service) endpoint.Endpoint

func MakeGetAddressEndpoint

func MakeGetAddressEndpoint(s Service) endpoint.Endpoint

func MakeGetAddressesEndpoint

func MakeGetAddressesEndpoint(s Service) endpoint.Endpoint

func MakeGetProfileEndpoint

func MakeGetProfileEndpoint(s Service) endpoint.Endpoint

func MakeHTTPHandler

func MakeHTTPHandler(s Service, logger log.Logger) http.Handler

func MakePatchProfileEndpoint

func MakePatchProfileEndpoint(s Service) endpoint.Endpoint

func MakePostAddressEndpoint

func MakePostAddressEndpoint(s Service) endpoint.Endpoint

func MakePostProfileEndpoint

func MakePostProfileEndpoint(s Service) endpoint.Endpoint

func MakePutProfileEndpoint

func MakePutProfileEndpoint(s Service) endpoint.Endpoint

Types

type Address

type Address struct {
	ID       string `json:"id"`
	Location string `json:"location,omitempty"`
}

type Endpoints

type Endpoints struct {
	PostProfileEndpoint   endpoint.Endpoint
	GetProfileEndpoint    endpoint.Endpoint
	PutProfileEndpoint    endpoint.Endpoint
	PatchProfileEndpoint  endpoint.Endpoint
	DeleteProfileEndpoint endpoint.Endpoint
	GetAddressesEndpoint  endpoint.Endpoint
	GetAddressEndpoint    endpoint.Endpoint
	PostAddressEndpoint   endpoint.Endpoint
	DeleteAddressEndpoint endpoint.Endpoint
}

func MakeClientEndpoint

func MakeClientEndpoint(instance string) (Endpoints, error)

func MakeServerEndpoints

func MakeServerEndpoints(s Service) Endpoints

func (Endpoints) DeleteAddress

func (e Endpoints) DeleteAddress(ctx context.Context, profileID string, addressID string) error

func (Endpoints) DeleteProfile

func (e Endpoints) DeleteProfile(ctx context.Context, id string) error

func (Endpoints) GetAddress

func (e Endpoints) GetAddress(ctx context.Context, profileID string, addressID string) (Address, error)

func (Endpoints) GetAddresses

func (e Endpoints) GetAddresses(ctx context.Context, profileID string) ([]Address, error)

func (Endpoints) GetProfile

func (e Endpoints) GetProfile(ctx context.Context, id string) (Profile, error)

func (Endpoints) PatchProfile

func (e Endpoints) PatchProfile(ctx context.Context, id string, p Profile) error

func (Endpoints) PostAddress

func (e Endpoints) PostAddress(ctx context.Context, profileID string, a Address) error

func (Endpoints) PostProfile

func (e Endpoints) PostProfile(ctx context.Context, p Profile) error

func (Endpoints) PutProfile

func (e Endpoints) PutProfile(ctx context.Context, id string, p Profile) error

type Middleware

type Middleware func(Service) Service

func LoggingMiddleware

func LoggingMiddleware(logger log.Logger) Middleware

type Profile

type Profile struct {
	ID        string    `json:"id"`
	Name      string    `json:"name,omitempty"`
	Addresses []Address `json:addresses,omitempty`
}

type Service

type Service interface {
	PostProfile(ctx context.Context, p Profile) error
	GetProfile(ctx context.Context, id string) (Profile, error)
	PutProfile(ctx context.Context, id string, p Profile) error
	PatchProfile(ctx context.Context, id string, p Profile) error
	DeleteProfile(ctx context.Context, id string) error
	GetAddresses(ctx context.Context, profileID string) ([]Address, error)
	GetAddress(ctx context.Context, profileID string, addressID string) (Address, error)
	PostAddress(ctx context.Context, profileID string, a Address) error
	DeleteAddress(ctx context.Context, profileID string, addressID string) error
}

func NewInmemService

func NewInmemService() Service

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

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