feat: add routes and basic controllers

This commit is contained in:
Yanislav Igonin 2021-08-26 20:23:55 +03:00
parent e87b085227
commit 6b72e3f843
2 changed files with 28 additions and 5 deletions

View File

@ -0,0 +1,23 @@
package controlers
import (
"net/http"
"github.com/gin-gonic/gin"
)
func GetThreads(c *gin.Context) {
c.JSON(http.StatusOK, gin.H{"route": "get threads"})
}
func GetThread(c *gin.Context) {
c.JSON(http.StatusOK, gin.H{"route": "get thread"})
}
func CreateThread(c *gin.Context) {
c.JSON(http.StatusOK, gin.H{"route": "create thread"})
}
func UpdateThread(c *gin.Context) {
c.JSON(http.StatusOK, gin.H{"route": "update thread"})
}

10
main.go
View File

@ -8,7 +8,7 @@ import (
_ "github.com/joho/godotenv/autoload" _ "github.com/joho/godotenv/autoload"
Config "micrach/config" Config "micrach/config"
// Controllers "micrach/controllers" Controllers "micrach/controllers"
Db "micrach/db" Db "micrach/db"
// Utils "micrach/utils" // Utils "micrach/utils"
) )
@ -20,10 +20,10 @@ func main() {
gin.SetMode(Config.App.Env) gin.SetMode(Config.App.Env)
router := gin.Default() router := gin.Default()
// router.GET("/boards", Controllers.GetAllBoards) router.GET("/", Controllers.GetThreads)
// router.GET("/threads/:boardId", Controllers.GetThreads) router.POST("/", Controllers.CreateThread)
// router.POST("/threads/:boardId", Controllers.CreateThread) router.GET("/:threadId", Controllers.GetThread)
// router.POST("/posts/:boardId/:threadId", Controllers.CreatePost) router.POST("/:threadId", Controllers.UpdateThread)
log.Println("all systems nominal") log.Println("all systems nominal")