Skip to content

Commit a539f8e

Browse files
committed
main: restapi profile func added
1 parent fea9e95 commit a539f8e

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

main.go

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import (
66
"github.com/krishpranav/gorestapi/api/aboutapi"
77
"github.com/krishpranav/gorestapi/api/album"
88
"github.com/krishpranav/gorestapi/api/artist"
9+
"github.com/krishpranav/gorestapi/api/profile"
910
"log"
1011
"net/http"
1112
)
@@ -30,6 +31,10 @@ var artists = []artist.Artist {
3031
{Name: "ArtistFive", Location: "USA", JoinedAt: 2021},
3132
}
3233

34+
var profile = []aboutme.Aboutme {
35+
{User: "UserOne", JoinedAt: 2020, Toptracks: "Song1, Song2, Song3", Following: "ArtistOne"},
36+
}
37+
3338
var mainpage = "Hello World"
3439

3540
func main() {
@@ -39,13 +44,14 @@ func main() {
3944

4045
api := router.Group("/api")
4146
{
42-
api.GET("/albums", getAlbums)
43-
router.GET("/albums/:id", getAlbumByID)
47+
router.GET("/albums", getAlbums)
48+
api.GET("/albums/:id", getAlbumByID)
4449
router.POST("/albums", postAlbums)
4550
router.GET("/about", getAbout)
4651
router.GET("/artist", getArtistData)
4752
router.POST("/artist", postArtist)
4853
router.GET("/", getMain)
54+
router.GET("/profile", getProfile)
4955

5056
}
5157

@@ -58,6 +64,10 @@ func main() {
5864
router.Run("localhost:8080")
5965
}
6066

67+
func getProfile(c *gin.Context) {
68+
c.IndentedJSON(http.StatusOK, profile)
69+
}
70+
6171
func getAlbums(c *gin.Context) {
6272
c.IndentedJSON(http.StatusOK, albums)
6373
}

0 commit comments

Comments
 (0)