Version: v0.0.0-...-bc4fcfc Latest Latest

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

Go to latest
Published: Sep 27, 2021 License: MIT Imports: 2 Imported by: 9




This section is empty.


View Source
var ErrNotFound = errors.New("beer not found")

ErrNotFound is used when a beer could not be found.


This section is empty.


type Beer

type Beer struct {
	ID        string    `json:"id"`
	Name      string    `json:"name"`
	Brewery   string    `json:"brewery"`
	Abv       float32   `json:"abv"`
	ShortDesc string    `json:"short_description"`
	Created   time.Time `json:"created"`

Beer defines the properties of a beer to be listed

type Repository

type Repository interface {
	// GetBeer returns the beer with given ID.
	GetBeer(string) (Beer, error)
	// GetAllBeers returns all beers saved in storage.
	GetAllBeers() []Beer
	// GetAllReviews returns a list of all reviews for a given beer ID.
	GetAllReviews(string) []Review

Repository provides access to the beer and review storage.

type Review

type Review struct {
	ID        string    `json:"id"`
	BeerID    string    `json:"beer_id"`
	FirstName string    `json:"first_name"`
	LastName  string    `json:"last_name"`
	Score     int       `json:"score"`
	Text      string    `json:"text"`
	Created   time.Time `json:"created"`

Review defines a beer review

type Service

type Service interface {
	GetBeer(string) (Beer, error)
	GetBeers() []Beer
	GetBeerReviews(string) []Review

Service provides beer and review listing operations.

func NewService

func NewService(r Repository) Service

NewService creates a listing service with the necessary dependencies

Jump to

Keyboard shortcuts

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