-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
45 lines (38 loc) · 1.3 KB
/
main.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
39
40
41
42
43
44
45
package main
import (
"HotKeysBackend/checking"
"HotKeysBackend/getting"
"HotKeysBackend/storage"
"HotKeysBackend/utils"
"fmt"
"github.com/gin-gonic/gin"
)
var (
handleGetPrograms = "/programs/"
handleGetProgram = fmt.Sprintf("/programs/:%s", utils.ProgramId)
handleGetHotkeys = fmt.Sprintf("/programs/:%s/hotkeys", utils.ProgramId)
handleCheckHotkey = fmt.Sprintf("/programs/:%s/hotkeys/:%s/check", utils.ProgramId, utils.HotkeyId)
)
func main() {
// TODO uncomment when database appears
//programStorage := storage.GetProgramDatabaseRepository()
//keyStorage := storage.GetKeyDatabaseRepository()
programStorage := storage.GetProgramInMemoryRepository()
keyStorage := storage.GetKeyInMemoryRepository()
getter := getting.CreateService(programStorage, keyStorage)
checker := checking.CreateService(programStorage, keyStorage)
router := gin.Default()
router.GET(handleGetPrograms, func(context *gin.Context) {
getting.HandleGetPrograms(context, getter)
})
router.GET(handleGetProgram, func(context *gin.Context) {
getting.HandleGetProgram(context, getter)
})
router.GET(handleGetHotkeys, func(context *gin.Context) {
getting.HandleGetHotkeys(context, getter)
})
router.POST(handleCheckHotkey, func(context *gin.Context) {
checking.HandleCheckHotkey(context, checker)
})
_ = router.Run()
}