Add initial database setup and user/artist management functionality
This commit is contained in:
@@ -0,0 +1,25 @@
|
||||
package handlers
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
"zardzul/music-index/repository"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
type ArtistHandler struct {
|
||||
repo repository.ArtistRepository
|
||||
}
|
||||
|
||||
func NewArtistHandler(repo repository.ArtistRepository) *ArtistHandler {
|
||||
return &ArtistHandler{repo: repo}
|
||||
}
|
||||
|
||||
func (handler *ArtistHandler) GetAll(c *gin.Context) {
|
||||
artists, err := handler.repo.GetAll(c.Request.Context())
|
||||
if err != nil {
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"error": err.Error()})
|
||||
}
|
||||
|
||||
c.JSON(http.StatusOK, artists)
|
||||
}
|
||||
Reference in New Issue
Block a user