From bd6f378b596b575de39932b6308011a0a68f3f55 Mon Sep 17 00:00:00 2001 From: Yanislav Igonin Date: Wed, 26 Jan 2022 19:42:23 +0200 Subject: [PATCH] disable api --- controllers/threads_controller.go | 84 +++++++++++++++---------------- main.go | 2 +- 2 files changed, 43 insertions(+), 43 deletions(-) diff --git a/controllers/threads_controller.go b/controllers/threads_controller.go index 92ca8ff..4b3fa8a 100644 --- a/controllers/threads_controller.go +++ b/controllers/threads_controller.go @@ -64,52 +64,52 @@ func GetThreads(c *gin.Context) { c.HTML(http.StatusOK, "index.html", htmlData) } -func GetThreadsApi(c *gin.Context) { - pageString := c.DefaultQuery("page", "1") - page, err := strconv.Atoi(pageString) - if err != nil { - c.HTML(http.StatusNotFound, "404.html", nil) - return - } +// func GetThreadsApi(c *gin.Context) { +// pageString := c.DefaultQuery("page", "1") +// page, err := strconv.Atoi(pageString) +// if err != nil { +// c.HTML(http.StatusNotFound, "404.html", nil) +// return +// } - if page <= 0 { - c.HTML(http.StatusNotFound, "404.html", nil) - return - } +// if page <= 0 { +// c.HTML(http.StatusNotFound, "404.html", nil) +// return +// } - limit := 10 - offset := limit * (page - 1) - threads, err := Repositories.Posts.Get(limit, offset) - if err != nil { - log.Println("error:", err) - c.HTML(http.StatusInternalServerError, "500.html", nil) - return - } - count, err := Repositories.Posts.GetCount() - if err != nil { - log.Println("error:", err) - c.HTML(http.StatusInternalServerError, "500.html", nil) - return - } +// limit := 10 +// offset := limit * (page - 1) +// threads, err := Repositories.Posts.Get(limit, offset) +// if err != nil { +// log.Println("error:", err) +// c.HTML(http.StatusInternalServerError, "500.html", nil) +// return +// } +// count, err := Repositories.Posts.GetCount() +// if err != nil { +// log.Println("error:", err) +// c.HTML(http.StatusInternalServerError, "500.html", nil) +// return +// } - pagesCount := int(math.Ceil(float64(count) / 10)) - if page > pagesCount && count != 0 { - c.HTML(http.StatusNotFound, "404.html", nil) - return - } +// pagesCount := int(math.Ceil(float64(count) / 10)) +// if page > pagesCount && count != 0 { +// c.HTML(http.StatusNotFound, "404.html", nil) +// return +// } - captchaID := captcha.New() - htmlData := Repositories.GetThreadsHtmlData{ - Threads: threads, - PagesCount: pagesCount, - Page: page, - FormData: Repositories.HtmlFormData{ - CaptchaID: captchaID, - }, - } - // c.HTML(http.StatusOK, "index.html", htmlData) - c.JSON(http.StatusOK, htmlData) -} +// captchaID := captcha.New() +// htmlData := Repositories.GetThreadsHtmlData{ +// Threads: threads, +// PagesCount: pagesCount, +// Page: page, +// FormData: Repositories.HtmlFormData{ +// CaptchaID: captchaID, +// }, +// } +// // c.HTML(http.StatusOK, "index.html", htmlData) +// c.JSON(http.StatusOK, htmlData) +// } func GetThread(c *gin.Context) { threadIDString := c.Param("threadID") diff --git a/main.go b/main.go index 7e09e0b..1b6c5bb 100644 --- a/main.go +++ b/main.go @@ -69,7 +69,7 @@ func main() { router.Static("/static", "./static") router.GET("/", Controllers.GetThreads) router.POST("/", Controllers.CreateThread) - router.GET("/api", Controllers.GetThreadsApi) + // router.GET("/api", Controllers.GetThreadsApi) router.GET("/:threadID", Controllers.GetThread) router.POST("/:threadID", Controllers.UpdateThread) router.GET("/captcha/:captchaID", Controllers.GetCaptcha)