mirror of
https://github.com/yanislav-igonin/micrach
synced 2025-04-20 03:40:33 +03:00
connect get thread by id controller
This commit is contained in:
parent
efa354eda7
commit
733f3cae5a
@ -53,39 +53,35 @@ func GetThreads(c *fiber.Ctx) error {
|
|||||||
IsCaptchaActive: config.App.IsCaptchaActive,
|
IsCaptchaActive: config.App.IsCaptchaActive,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
return c.Status(fiber.StatusOK).Render("pages/index", htmlData)
|
return c.Render("pages/index", htmlData)
|
||||||
}
|
}
|
||||||
|
|
||||||
// func GetThread(c *gin.Context) {
|
func GetThread(c *fiber.Ctx) error {
|
||||||
// threadIDString := c.Param("threadID")
|
threadID, err := c.ParamsInt("threadID")
|
||||||
// threadID, err := strconv.Atoi(threadIDString)
|
if err != nil {
|
||||||
// if err != nil {
|
return c.Status(fiber.StatusNotFound).Render("pages/404", nil)
|
||||||
// c.HTML(http.StatusNotFound, "404.html", nil)
|
}
|
||||||
// return
|
thread, err := repositories.Posts.GetThreadByPostID(threadID)
|
||||||
// }
|
if err != nil {
|
||||||
// thread, err := Repositories.Posts.GetThreadByPostID(threadID)
|
log.Println("error:", err)
|
||||||
// if err != nil {
|
return c.Status(fiber.StatusInternalServerError).Render("pages/500", nil)
|
||||||
// log.Println("error:", err)
|
}
|
||||||
// c.HTML(http.StatusInternalServerError, "500.html", nil)
|
if thread == nil {
|
||||||
// return
|
return c.Status(fiber.StatusNotFound).Render("pages/404", nil)
|
||||||
// }
|
}
|
||||||
// if thread == nil {
|
|
||||||
// c.HTML(http.StatusNotFound, "404.html", nil)
|
|
||||||
// return
|
|
||||||
// }
|
|
||||||
|
|
||||||
// firstPost := thread[0]
|
firstPost := thread[0]
|
||||||
// captchaID := captcha.New()
|
captchaID := captcha.New()
|
||||||
// htmlData := Repositories.GetThreadHtmlData{
|
htmlData := repositories.GetThreadHtmlData{
|
||||||
// Thread: thread,
|
Thread: thread,
|
||||||
// FormData: Repositories.HtmlFormData{
|
FormData: repositories.HtmlFormData{
|
||||||
// FirstPostID: firstPost.ID,
|
FirstPostID: firstPost.ID,
|
||||||
// CaptchaID: captchaID,
|
CaptchaID: captchaID,
|
||||||
// IsCaptchaActive: Config.App.IsCaptchaActive,
|
IsCaptchaActive: config.App.IsCaptchaActive,
|
||||||
// },
|
},
|
||||||
// }
|
}
|
||||||
// c.HTML(http.StatusOK, "thread.html", htmlData)
|
return c.Render("pages/thread", htmlData)
|
||||||
// }
|
}
|
||||||
|
|
||||||
// func CreateThread(c *gin.Context) {
|
// func CreateThread(c *gin.Context) {
|
||||||
// form, err := c.MultipartForm()
|
// form, err := c.MultipartForm()
|
||||||
|
4
main.go
4
main.go
@ -71,9 +71,7 @@ func main() {
|
|||||||
app.Post("/", func(c *fiber.Ctx) error {
|
app.Post("/", func(c *fiber.Ctx) error {
|
||||||
return c.SendString("create thread")
|
return c.SendString("create thread")
|
||||||
})
|
})
|
||||||
app.Get("/:threadID", func(c *fiber.Ctx) error {
|
app.Get("/:threadID", controllers.GetThread)
|
||||||
return c.SendString("get thread by id")
|
|
||||||
})
|
|
||||||
app.Post("/threadID", func(c *fiber.Ctx) error {
|
app.Post("/threadID", func(c *fiber.Ctx) error {
|
||||||
return c.SendString("create post in thread")
|
return c.SendString("create post in thread")
|
||||||
})
|
})
|
||||||
|
Loading…
Reference in New Issue
Block a user