-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrouter.go
38 lines (28 loc) · 1.12 KB
/
router.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
package infrastructure
import (
"os"
"github.com/gin-gonic/gin"
"github.com/kindai-csg/d-blog-engine/interfaces/controller"
"github.com/kindai-csg/d-blog-engine/interfaces/database"
)
var Router *gin.Engine
func init() {
router := gin.Default()
endpoint := os.Getenv("D_BLOG_ENGINE_ENDPOINT")
accessToken := os.Getenv("D_BLOG_ENGINE_ACCESSTOKEN")
userId := os.Getenv("D_BLOG_ENGINE_USERID")
password := os.Getenv("D_BLOG_ENGINE_PASSWORD")
hugoDir := os.Getenv("D_BLOG_ENGINE_HUGODIR")
fileHandler := NewFileHandler()
growiHandler := NewGrowiHandler(endpoint, accessToken, userId, password)
hugoHandler := NewHugoHandler(hugoDir)
articleRepository := database.NewArticleRepository(fileHandler, growiHandler, hugoHandler, hugoDir + "/static/attachment/", hugoDir + "/content/post/")
articleController := controller.NewArticleController(articleRepository)
router.POST("/post", func(c *gin.Context) { articleController.PostArticle(c) })
router.GET("/", func(c *gin.Context) {
c.JSON(200, gin.H{
"msg": "hello world",
})
})
Router = router
}