From 7dd0d74b1244334cc41f03d4d2acc2fdd41001f8 Mon Sep 17 00:00:00 2001 From: cyber-dream Date: Wed, 15 Mar 2023 15:32:41 +0300 Subject: [PATCH] add route for personal props app --- .../personalPropsRoute/personalPropsRoute.go | 16 ++++++++ main.go | 7 +++- websiteapp/personalprops/personalprops.go | 39 +++++++++++++++++++ 3 files changed, 61 insertions(+), 1 deletion(-) create mode 100644 approutes/personalPropsRoute/personalPropsRoute.go create mode 100644 websiteapp/personalprops/personalprops.go diff --git a/approutes/personalPropsRoute/personalPropsRoute.go b/approutes/personalPropsRoute/personalPropsRoute.go new file mode 100644 index 0000000..99f8618 --- /dev/null +++ b/approutes/personalPropsRoute/personalPropsRoute.go @@ -0,0 +1,16 @@ +package personalpropsroute + +import ( + "net/http" + "personalwebsite/websiteapp/personalprops" + + "github.com/gin-gonic/gin" +) + +func Route(route *gin.RouterGroup) { + persPropsApp := personalprops.NewPersPropsApp() + route.GET("/test", func(ctx *gin.Context) { + test := persPropsApp.Render() + ctx.HTML(http.StatusOK, "personal-properties.html", gin.H{"books": test}) + }) +} diff --git a/main.go b/main.go index 10999ae..8192d61 100644 --- a/main.go +++ b/main.go @@ -3,6 +3,7 @@ package main import ( "log" "net/http" + personalpropsroute "personalwebsite/approutes/personalPropsRoute" "github.com/gin-gonic/gin" ) @@ -17,8 +18,12 @@ func main() { router.Static("/res", "resources") router.GET("/", index) router.GET("/getmockapp", func(ctx *gin.Context) { - ctx.HTML(http.StatusOK, "mockapp.html", nil) + }) + apps := router.Group("applications") + { + personalpropsroute.Route(apps.Group("/personalproperties")) + } // router.GET("/room/:roomid", roomGET) // router.POST("/room-post/:roomid", roomPOST) // router.GET("/stream/:roomid", streamRoom) diff --git a/websiteapp/personalprops/personalprops.go b/websiteapp/personalprops/personalprops.go new file mode 100644 index 0000000..c5f02e0 --- /dev/null +++ b/websiteapp/personalprops/personalprops.go @@ -0,0 +1,39 @@ +package personalprops + +type PersonalPropertiesApp struct { +} + +func NewPersPropsApp() PersonalPropertiesApp { + newApp := PersonalPropertiesApp{} + return newApp +} + +func (p *PersonalPropertiesApp) Render() []Book { + books := make([]Book, 0) + books = append(books, Book{ + Title: "About person:", + Author: "General information about me", + }) + books = append(books, Book{ + Title: "Career:", + Author: "Inforamtion about my career", + }) + books = append(books, Book{ + Title: "TEST:", + Author: "QQQQQQQ", + }) + books = append(books, Book{ + Title: "TEST:", + Author: "QQQQQQQ", + }) + books = append(books, Book{ + Title: "TEST:", + Author: "QQQQQQQ", + }) + return books +} + +type Book struct { + Title string + Author string +}