package handlers import ( "CatsOfMastodonBotGo/internal/services" "github.com/gin-gonic/gin" ) type ApiEndpointHandler struct { postService *services.PostService imgKitHelper *services.ImgKitHelper } func NewApiEndpointHandler( postService *services.PostService, imgKitHelper *services.ImgKitHelper, ) *ApiEndpointHandler { return &ApiEndpointHandler{ postService: postService, imgKitHelper: imgKitHelper, } } func (aeh *ApiEndpointHandler) GetRandomPost(c *gin.Context) { post := aeh.postService.GetRandomPost() for i := range post.Attachments { post.Attachments[i].RemoteUrl = aeh.imgKitHelper.GetRemoteUrl(post.Attachments[i].RemoteUrl) post.Attachments[i].PreviewUrl = aeh.imgKitHelper.GetPreviewUrl(post.Attachments[i].RemoteUrl) } c.JSON(200, post) }