forked from yockliu/AppManager
/
main.go
53 lines (41 loc) · 1.08 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
51
52
53
package main
import (
"./appmanager"
"./mongodb"
"./route"
"net/http"
// "encoding/base64"
"fmt"
"github.com/go-martini/martini"
"github.com/martini-contrib/auth"
"github.com/martini-contrib/render"
// "time"
)
func main() {
fmt.Println("Hello, let's go!")
// aaa := base64.StdEncoding.EncodeToString([]byte("admin:guessme"))
// fmt.Println(aaa)
mongodb.Init()
m := martini.Classic()
m.Use(auth.BasicFunc(func(username, password string) bool {
fmt.Println("username = " + username)
fmt.Println("password = " + password)
return auth.SecureCompare(username, "admin") && auth.SecureCompare(password, "guessme")
}))
m.Use(martini.Static("client"))
m.Use(martini.Static("static"))
fileServer := http.FileServer(http.Dir("./static"))
m.Any("/apk/**", func(res http.ResponseWriter, req *http.Request) {
fmt.Println("/apk/")
fileServer.ServeHTTP(res, req)
})
m.Use(render.Renderer(render.Options{
Directory: "templates",
Layout: "layout",
Extensions: []string{".tmpl", ".html"},
}))
route.Route(m)
appmanager.Init()
appmanager.RouteApi(m)
m.Run()
}