Add API endpoint for random post with preloaded relationships
This commit is contained in:
@@ -0,0 +1,22 @@
|
||||
package handlers_api
|
||||
|
||||
import (
|
||||
"CatsOfMastodonBotGo/internal"
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
type ApiEndpointHandler struct {
|
||||
AppContext *internal.AppContext
|
||||
}
|
||||
|
||||
func NewApiEndpointHandler(appContext *internal.AppContext) *ApiEndpointHandler {
|
||||
return &ApiEndpointHandler{
|
||||
AppContext: appContext,
|
||||
}
|
||||
}
|
||||
|
||||
func (appContext *ApiEndpointHandler) GetRandomPost(c *gin.Context) {
|
||||
c.JSON(200, gin.H{
|
||||
"post": appContext.AppContext.PostService.GetRandomPost(),
|
||||
})
|
||||
}
|
||||
Reference in New Issue
Block a user