Refactor
Signed-off-by: Oliver Davies <oliver@oliverdavies.uk>
This commit is contained in:
parent
a10fc038fd
commit
238571521d
2 changed files with 4 additions and 4 deletions
|
|
@ -1,4 +1,4 @@
|
||||||
package lib
|
package albums
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"net/http"
|
"net/http"
|
||||||
|
|
@ -19,6 +19,6 @@ var albums = []album{
|
||||||
{ID: "3", Title: "Sarah Vaughan and Clifford Brown", Artist: "Sarah Vaughan", Price: 39.99},
|
{ID: "3", Title: "Sarah Vaughan and Clifford Brown", Artist: "Sarah Vaughan", Price: 39.99},
|
||||||
}
|
}
|
||||||
|
|
||||||
func GetAlbums(c *gin.Context) {
|
func GetAll(c *gin.Context) {
|
||||||
c.IndentedJSON(http.StatusOK, albums)
|
c.IndentedJSON(http.StatusOK, albums)
|
||||||
}
|
}
|
||||||
|
|
@ -5,13 +5,13 @@ import (
|
||||||
|
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
|
|
||||||
"code.oliverdavies.uk/opdavies/lab/go-gin/internal/lib"
|
"code.oliverdavies.uk/opdavies/lab/go-gin/internal/albums"
|
||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
r := gin.Default()
|
r := gin.Default()
|
||||||
|
|
||||||
r.GET("/albums", lib.GetAlbums)
|
r.GET("/albums", albums.GetAll)
|
||||||
|
|
||||||
r.GET("/ping", func(c *gin.Context) {
|
r.GET("/ping", func(c *gin.Context) {
|
||||||
c.JSON(http.StatusOK, gin.H{
|
c.JSON(http.StatusOK, gin.H{
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue