forked from AlexsJones/choke
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
50 lines (36 loc) · 1.11 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
46
47
48
49
50
package main
import (
"github.com/AlexsJones/choke/src/database"
"github.com/AlexsJones/choke/src/database/mongo"
"github.com/AlexsJones/choke/src/queue"
"github.com/AlexsJones/choke/src/routes"
"github.com/kataras/iris/v12"
)
/************************************/
var configuration = mongo.NewMongodbConfiguration(func(config *mongo.MongodbConfiguration) {
config.Hosts = []string{"localhost"}
})
var m = mongo.NewMongodbConnector(configuration)
var q = queue.NewQueue()
/************************************/
func main() {
/*********/
//Connect persistant connector to mongo
database.Connect(m)
/********/
app := iris.New()
app.OnErrorCode(iris.StatusInternalServerError, func(ctx iris.Context) {
errMessage := ctx.Values().GetString("error")
if errMessage != "" {
ctx.Writef("Internal server error: %s", errMessage)
return
}
ctx.WriteString("(Unexpected) internal server error")
})
app.RegisterView(iris.HTML("./views", ".html").Reload(true))
routes.AddRoutes(app, m, q)
app.Get("/data", func(ctx iris.Context) {
})
go q.Run()
app.Run(iris.Addr(":8080"), iris.WithCharset("UTF-8"))
}