Documentation ¶
Index ¶
- Constants
- func NewRouter() *mux.Router
- type Album
- type Albums
- type Controller
- func (c *Controller) AddAlbum(w http.ResponseWriter, r *http.Request)
- func (c *Controller) DeleteAlbum(w http.ResponseWriter, r *http.Request)
- func (c *Controller) GetAlbum(w http.ResponseWriter, r *http.Request)
- func (c *Controller) Index(w http.ResponseWriter, r *http.Request)
- func (c *Controller) UpdateAlbum(w http.ResponseWriter, r *http.Request)
- type Repository
- type Route
- type Routes
Constants ¶
View Source
const ( SERVER = "127.0.0.1:27017" DBNAME = "musicstore" DOCNAME = "albums" )
Constants
Variables ¶
This section is empty.
Functions ¶
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 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
Click to show internal directories.
Click to hide internal directories.