Seperate API from UI

This commit is contained in:
video-prize-ranch
2023-01-01 15:12:03 -05:00
parent e03abd0ab9
commit a3feae6b30
11 changed files with 79 additions and 58 deletions

View File

@@ -17,11 +17,11 @@ func HandlePost(c *fiber.Ctx) error {
post, err := api.Album{}, error(nil)
switch {
case strings.HasPrefix(c.Path(), "/a"):
post, err = api.FetchAlbum(c.Params("postID"))
post, err = ApiClient.FetchAlbum(c.Params("postID"))
case strings.HasPrefix(c.Path(), "/gallery"):
post, err = api.FetchPosts(c.Params("postID"))
post, err = ApiClient.FetchPosts(c.Params("postID"))
default:
post, err = api.FetchMedia(c.Params("postID"))
post, err = ApiClient.FetchMedia(c.Params("postID"))
}
if err != nil && err.Error() == "ratelimited by imgur" {
return c.Status(429).Render("errors/429", nil)
@@ -36,7 +36,7 @@ func HandlePost(c *fiber.Ctx) error {
comments := []api.Comment{}
if post.SharedWithCommunity {
c.Set("Cache-Control", "public,max-age=604800")
comments, err = api.FetchComments(c.Params("postID"))
comments, err = ApiClient.FetchComments(c.Params("postID"))
if err != nil {
return err
}