-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.go
41 lines (32 loc) · 842 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
package main
import (
"log"
"net/http"
"github.com/cu-sage/sage/handlers"
"github.com/cu-sage/sage/repositories"
"github.com/cu-sage/sage/utils"
ghandlers "github.com/gorilla/handlers"
)
const (
port = ":8081"
)
func main() {
session, err := repositories.GetMongoSession()
if err != nil {
log.Panicf("Cannot connect to database. Exiting...")
}
defer session.Close()
a := handlers.NewAssessmentHandler(
repositories.NewRepository(session),
utils.ReadPluginConfig("plugins.json"),
)
r := handlers.RegisterHandlers(a)
log.Printf("Listening on port %s\n", port)
allowedHeaders := []string{"Content-Type"}
allowedMethods := []string{"POST", "GET", "OPTIONS"}
log.Fatal(http.ListenAndServe(port,
ghandlers.CORS(
ghandlers.AllowedMethods(allowedMethods),
ghandlers.AllowedHeaders(allowedHeaders),
)(r)))
}