album

package
v0.0.0-...-a1d8a75 Latest Latest
Warning

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

Go to latest
Published: Jun 22, 2018 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	SERVER  = "127.0.0.1:27017"
	DBNAME  = "musicstore"
	DOCNAME = "albums"
)

Constants

Variables

This section is empty.

Functions

func NewRouter

func NewRouter() *mux.Router

NewRouter configures a router for the API

Types

type Album

type Album struct {
	ID     bson.ObjectId `bson:"_id"`
	Title  string        `json:"title"`
	Artist string        `json:"artist"`
	Year   int32         `json:"year"`
}

Album is a music album

type Albums

type Albums []Album

Albums is an array of Album

type Controller

type Controller struct {
	Repository Repository
}

Controller is the Album controller

func (*Controller) AddAlbum

func (c *Controller) AddAlbum(w http.ResponseWriter, r *http.Request)

AddAlbum adds an album

func (*Controller) DeleteAlbum

func (c *Controller) DeleteAlbum(w http.ResponseWriter, r *http.Request)

DeleteAlbum deletes an album

func (*Controller) GetAlbum

func (c *Controller) GetAlbum(w http.ResponseWriter, r *http.Request)

GetAlbum returns an album

func (*Controller) Index

func (c *Controller) Index(w http.ResponseWriter, r *http.Request)

Index return a list of albums

func (*Controller) UpdateAlbum

func (c *Controller) UpdateAlbum(w http.ResponseWriter, r *http.Request)

UpdateAlbum updates an album

type Repository

type Repository struct{}

Repository ...

func (Repository) AddAlbum

func (r Repository) AddAlbum(album Album) (*Album, error)

AddAlbum adds an album to the database

func (Repository) DeleteAlbum

func (r Repository) DeleteAlbum(id string) bool

DeleteAlbum deletes an existing album

func (Repository) GetAlbum

func (r Repository) GetAlbum(id string) (*Album, error)

GetAlbum returns a single album

func (Repository) GetAlbums

func (r Repository) GetAlbums() Albums

GetAlbums returns the list of albums

func (Repository) UpdateAlbum

func (r Repository) UpdateAlbum(album Album) (*Album, error)

UpdateAlbum updates an existing album

type Route

type Route struct {
	Name        string
	Method      string
	Pattern     string
	HandlerFunc http.HandlerFunc
}

Route defines a route

type Routes

type Routes []Route

Routes defines the list of routes

Jump to

Keyboard shortcuts

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