-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
40 lines (33 loc) · 916 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
// Package main starts Wisply
package main
import (
"html/template"
"net/http"
"github.com/astaxie/beego"
database "github.com/cristian-sima/Wisply/models/database"
_ "github.com/cristian-sima/Wisply/routers"
)
func init() {
database := database.Db{}
database.Init()
}
func main() {
beego.DirectoryIndex = true
beego.StaticDir["/beeapi"] = "beeapi"
beego.Errorhandler("404", loadPageNotFound)
beego.Errorhandler("show-database-error", loadDatabaseError)
beego.Run()
}
func loadPageNotFound(rw http.ResponseWriter, r *http.Request) {
path := "/errors/404.html"
loadError(rw, r, path)
}
func loadDatabaseError(rw http.ResponseWriter, r *http.Request) {
path := "/errors/database.html"
loadError(rw, r, path)
}
func loadError(rw http.ResponseWriter, r *http.Request, path string) {
t, _ := template.ParseFiles(beego.ViewsPath + path)
data := make(map[string]interface{})
t.Execute(rw, data)
}