added project files
This commit is contained in:
28
src/main.go
Normal file
28
src/main.go
Normal file
@@ -0,0 +1,28 @@
|
||||
package main
|
||||
|
||||
import "net/http"
|
||||
import "github.com/gin-gonic/gin"
|
||||
|
||||
type album struct {
|
||||
Id string `json:"id"`
|
||||
Title string `json:"title"`
|
||||
Artist string `json:"artist"`
|
||||
Price float64 `json:"price"`
|
||||
}
|
||||
|
||||
var albums = []album{
|
||||
{Id: "1", Title: "Blue Train", Artist: "John Coltrane", Price: 56.99},
|
||||
{Id: "2", Title: "Jeru", Artist: "Gerry Mulligan", Price: 17.99},
|
||||
{Id: "3", Title: "Sarah Vaughan and Clifford Brown", Artist: "Sarah Vaughan", Price: 39.99},
|
||||
}
|
||||
|
||||
func getAlbums(c *gin.Context) {
|
||||
c.JSON(http.StatusOK, albums)
|
||||
}
|
||||
|
||||
func main() {
|
||||
router := gin.Default()
|
||||
router.GET("/albums", getAlbums)
|
||||
|
||||
router.Run("localhost:4500")
|
||||
}
|
||||
Reference in New Issue
Block a user