-
Notifications
You must be signed in to change notification settings - Fork 50
/
main.go
67 lines (58 loc) · 1.37 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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
package main
//go:generate goasset asset.json
import (
"flag"
"fmt"
"log"
"strings"
"github.com/hidu/api-front/proxy"
)
var confPath = flag.String("conf", "./conf/server.json", "server conf path")
var confDemo = flag.Bool("conf_demo", false, "show the demo conf")
func init() {
log.SetFlags(log.Lshortfile | log.LstdFlags | log.Ldate)
ua := flag.Usage
flag.Usage = func() {
ua()
fmt.Println("\n site: https://github.com/hidu/api-front")
fmt.Println(" version:", proxy.APIFrontVersion)
}
}
func main() {
flag.Parse()
if *confDemo {
showConfDemo()
return
}
manager := proxy.NewAPIServerManager(*confPath)
manager.Start()
}
func showConfDemo() {
conf := `
1. conf/server.json:
---------------------------------------------------------
{
"users":["admin"]
}
---------------------------------------------------------
2. conf/users:
---------------------------------------------------------
id:admin psw_md5:7bb483729b5a8e26f73e1831cde5b842 psw:psw
---------------------------------------------------------
3. conf/vhost/8080.json
---------------------------------------------------------
{
"port": 8080,
"group": "order",
"name": "order api",
"enable": true,
"hidden_cookie": true,
"note": "订单相关接口",
"users": [
"test"
]
}
---------------------------------------------------------
`
fmt.Println(strings.TrimSpace(conf))
}