mirror of
https://github.com/yanislav-igonin/micrach
synced 2024-12-22 22:32:33 +03:00
feat: add routes and basic controllers
This commit is contained in:
parent
e87b085227
commit
6b72e3f843
23
controllers/threads_controller.go
Normal file
23
controllers/threads_controller.go
Normal 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
10
main.go
@ -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")
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user