-
Notifications
You must be signed in to change notification settings - Fork 0
/
cloud.go
45 lines (37 loc) · 845 Bytes
/
cloud.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 slackpaul
import (
"database/sql"
"fmt"
"github.com/CedricFinance/slackpaul/application"
"github.com/CedricFinance/slackpaul/config"
"github.com/CedricFinance/slackpaul/database"
"github.com/CedricFinance/slackpaul/infrastructure/repository"
"math/rand"
"net/http"
"time"
)
var db *sql.DB
var server *application.Server
func init() {
rand.Seed(time.Now().Unix())
cfg, err := config.LoadConfig()
if err != nil {
fmt.Print(err)
return
}
db = database.Connect(
cfg.GetDBUsername(),
cfg.GetDBPassword(),
cfg.GetDBName(),
cfg.GetDBHost(),
)
server = &application.Server{
Repository: repository.New(db),
}
}
func OnSlashCommandTrigger(w http.ResponseWriter, r *http.Request) {
server.HandleSlashCommand(w, r)
}
func OnActionTrigger(w http.ResponseWriter, r *http.Request) {
server.HandleAction(w, r)
}