mirror of
https://github.com/yanislav-igonin/micrach
synced 2024-12-22 14:22:33 +03:00
disable api
This commit is contained in:
parent
d74fb8a246
commit
bd6f378b59
@ -64,52 +64,52 @@ func GetThreads(c *gin.Context) {
|
|||||||
c.HTML(http.StatusOK, "index.html", htmlData)
|
c.HTML(http.StatusOK, "index.html", htmlData)
|
||||||
}
|
}
|
||||||
|
|
||||||
func GetThreadsApi(c *gin.Context) {
|
// func GetThreadsApi(c *gin.Context) {
|
||||||
pageString := c.DefaultQuery("page", "1")
|
// pageString := c.DefaultQuery("page", "1")
|
||||||
page, err := strconv.Atoi(pageString)
|
// page, err := strconv.Atoi(pageString)
|
||||||
if err != nil {
|
// if err != nil {
|
||||||
c.HTML(http.StatusNotFound, "404.html", nil)
|
// c.HTML(http.StatusNotFound, "404.html", nil)
|
||||||
return
|
// return
|
||||||
}
|
// }
|
||||||
|
|
||||||
if page <= 0 {
|
// if page <= 0 {
|
||||||
c.HTML(http.StatusNotFound, "404.html", nil)
|
// c.HTML(http.StatusNotFound, "404.html", nil)
|
||||||
return
|
// return
|
||||||
}
|
// }
|
||||||
|
|
||||||
limit := 10
|
// limit := 10
|
||||||
offset := limit * (page - 1)
|
// offset := limit * (page - 1)
|
||||||
threads, err := Repositories.Posts.Get(limit, offset)
|
// threads, err := Repositories.Posts.Get(limit, offset)
|
||||||
if err != nil {
|
// if err != nil {
|
||||||
log.Println("error:", err)
|
// log.Println("error:", err)
|
||||||
c.HTML(http.StatusInternalServerError, "500.html", nil)
|
// c.HTML(http.StatusInternalServerError, "500.html", nil)
|
||||||
return
|
// return
|
||||||
}
|
// }
|
||||||
count, err := Repositories.Posts.GetCount()
|
// count, err := Repositories.Posts.GetCount()
|
||||||
if err != nil {
|
// if err != nil {
|
||||||
log.Println("error:", err)
|
// log.Println("error:", err)
|
||||||
c.HTML(http.StatusInternalServerError, "500.html", nil)
|
// c.HTML(http.StatusInternalServerError, "500.html", nil)
|
||||||
return
|
// return
|
||||||
}
|
// }
|
||||||
|
|
||||||
pagesCount := int(math.Ceil(float64(count) / 10))
|
// pagesCount := int(math.Ceil(float64(count) / 10))
|
||||||
if page > pagesCount && count != 0 {
|
// if page > pagesCount && count != 0 {
|
||||||
c.HTML(http.StatusNotFound, "404.html", nil)
|
// c.HTML(http.StatusNotFound, "404.html", nil)
|
||||||
return
|
// return
|
||||||
}
|
// }
|
||||||
|
|
||||||
captchaID := captcha.New()
|
// captchaID := captcha.New()
|
||||||
htmlData := Repositories.GetThreadsHtmlData{
|
// htmlData := Repositories.GetThreadsHtmlData{
|
||||||
Threads: threads,
|
// Threads: threads,
|
||||||
PagesCount: pagesCount,
|
// PagesCount: pagesCount,
|
||||||
Page: page,
|
// Page: page,
|
||||||
FormData: Repositories.HtmlFormData{
|
// FormData: Repositories.HtmlFormData{
|
||||||
CaptchaID: captchaID,
|
// CaptchaID: captchaID,
|
||||||
},
|
// },
|
||||||
}
|
// }
|
||||||
// c.HTML(http.StatusOK, "index.html", htmlData)
|
// // c.HTML(http.StatusOK, "index.html", htmlData)
|
||||||
c.JSON(http.StatusOK, htmlData)
|
// c.JSON(http.StatusOK, htmlData)
|
||||||
}
|
// }
|
||||||
|
|
||||||
func GetThread(c *gin.Context) {
|
func GetThread(c *gin.Context) {
|
||||||
threadIDString := c.Param("threadID")
|
threadIDString := c.Param("threadID")
|
||||||
|
2
main.go
2
main.go
@ -69,7 +69,7 @@ func main() {
|
|||||||
router.Static("/static", "./static")
|
router.Static("/static", "./static")
|
||||||
router.GET("/", Controllers.GetThreads)
|
router.GET("/", Controllers.GetThreads)
|
||||||
router.POST("/", Controllers.CreateThread)
|
router.POST("/", Controllers.CreateThread)
|
||||||
router.GET("/api", Controllers.GetThreadsApi)
|
// router.GET("/api", Controllers.GetThreadsApi)
|
||||||
router.GET("/:threadID", Controllers.GetThread)
|
router.GET("/:threadID", Controllers.GetThread)
|
||||||
router.POST("/:threadID", Controllers.UpdateThread)
|
router.POST("/:threadID", Controllers.UpdateThread)
|
||||||
router.GET("/captcha/:captchaID", Controllers.GetCaptcha)
|
router.GET("/captcha/:captchaID", Controllers.GetCaptcha)
|
||||||
|
Loading…
Reference in New Issue
Block a user