Refactor handlers into separate packages and implement dependency injection.
IDK if this shit is good or even logical, but it works and I can wrap my head around it.
This commit is contained in:
@@ -0,0 +1,23 @@
|
||||
package handlers_home
|
||||
|
||||
import (
|
||||
"CatsOfMastodonBotGo/internal"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
type MainPageHandler struct{
|
||||
AppContext *internal.AppContext
|
||||
}
|
||||
|
||||
func NewMainPageHandler(appContext *internal.AppContext) *MainPageHandler {
|
||||
return &MainPageHandler{
|
||||
AppContext: appContext,
|
||||
}
|
||||
}
|
||||
|
||||
func (appContext *MainPageHandler) HomePageHandler(c *gin.Context) {
|
||||
c.JSON(200, gin.H{
|
||||
"YouAreOn": "HomePage",
|
||||
})
|
||||
}
|
||||
Reference in New Issue
Block a user