2023-05-27 07:57:01 +00:00
|
|
|
package routes
|
|
|
|
|
2023-05-27 08:04:41 +00:00
|
|
|
import (
|
|
|
|
"github.com/gofiber/fiber/v2"
|
|
|
|
"github.com/medium.rip/pkg/client"
|
|
|
|
)
|
2023-05-27 07:57:01 +00:00
|
|
|
|
|
|
|
func show(c *fiber.Ctx) error {
|
2023-05-27 08:04:41 +00:00
|
|
|
postId := c.Params("id", "")
|
|
|
|
if postId == "" {
|
|
|
|
return c.Redirect("/")
|
|
|
|
}
|
|
|
|
|
|
|
|
e, err := client.PostData(postId)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
return c.JSON(e)
|
2023-05-27 07:57:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func index(c *fiber.Ctx) error {
|
|
|
|
return c.Render("index", fiber.Map {
|
|
|
|
"Title": "medium.rip",
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
func RegisterRoutes(app *fiber.App) {
|
|
|
|
app.Get("/", index)
|
|
|
|
app.Get("/:id", show)
|
|
|
|
}
|