-
Notifications
You must be signed in to change notification settings - Fork 3
/
http_server.go
34 lines (28 loc) · 914 Bytes
/
http_server.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
package main
import (
"github.com/gin-gonic/gin"
"github.com/ildarusmanov/msofficepreview/controllers"
"github.com/ildarusmanov/msofficepreview/interfaces"
)
func CreateRouter(serviceLocator interfaces.ServiceLocator) *gin.Engine {
wopiC := controllers.CreateWopiController(
serviceLocator.Get("Storage").(interfaces.Storage),
serviceLocator.Get("TokenProvider").(interfaces.TokenProvider),
)
previewsC := controllers.CreatePreviewsController(
serviceLocator.Get("PreviewGenerator").(interfaces.PreviewGenerator),
)
statusC := controllers.CreateStatusController()
r := gin.Default()
wopi := r.Group("/wopi")
{
wopi.GET("/files/:fileId/contents", wopiC.CreateAction(wopiC.GetFile))
wopi.GET("/files/:fileId", wopiC.CreateAction(wopiC.CheckFileInfo))
}
apiv1 := r.Group("/api/v1")
{
apiv1.POST("/previews", previewsC.Create)
apiv1.GET("/status/check", statusC.Check)
}
return r
}