-
Notifications
You must be signed in to change notification settings - Fork 2
/
main.go
47 lines (34 loc) · 938 Bytes
/
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
46
47
package main
import (
"flag"
"log"
"github.com/carlaKC/lightning-poll/db"
"github.com/carlaKC/lightning-poll/lnd"
"github.com/carlaKC/lightning-poll/polls"
"github.com/carlaKC/lightning-poll/votes"
"github.com/gin-gonic/gin"
)
var router *gin.Engine
var baseTemplates = flag.String("templates_base",
"/Users/carla/personal/src/github.com/carlaKC", "location of templates")
func main() {
flag.Parse()
// Set the router as the default one provided by Gin
router = gin.Default()
router.LoadHTMLGlob(*baseTemplates + "/lightning-poll/templates/*")
dbc, err := db.Connect()
if err != nil {
log.Fatalf("could not connect to DB: %v", err)
}
lndCl, err := lnd.New()
if err != nil {
log.Fatalf("could not connect to LND: %v", err)
}
env := &Env{db: dbc, lnd: lndCl}
votes.StartLoops(env)
polls.StartLoops(env)
// Initialize the routes
initializeRoutes(env)
// Start serving the application
router.Run()
}