-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
76 lines (54 loc) · 1.42 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
68
69
70
71
72
73
74
75
76
package main
import (
"website-gateway/server"
"github.com/mkideal/cli"
)
type cliArgs struct {
cli.Helper
ConnectionStr string `cli:"*c,*conn" usage:"mysql connection str" dft:"$GATEWAY_CONN_STR"`
ListenAddr string `cli:"*l,*listen" usage:"gateway listen host and port" dft:"$GATEWAY_LS"`
ResourceURL string `cli:"*r,*resource" usage:"gateway resource url" dft:"$GATEWAY_RESOURCE_URL"`
}
func main() {
cli.Run(new(cliArgs), func(ctx *cli.Context) error {
argv := ctx.Argv().(*cliArgs)
server.NewGatewayServer(argv.ConnectionStr, argv.ResourceURL).Start(argv.ListenAddr)
return nil
})
}
/*
package main
import (
"html/template"
"io"
"net/http"
"github.com/labstack/echo"
)
type Template struct {
templates *template.Template
}
func (t *Template) Render(w io.Writer, name string, data interface{}, c echo.Context) error {
return t.templates.ExecuteTemplate(w, name, data)
}
func (t *Template) AddTemplate() {
}
func main() {
e := echo.New()
t := &Template{
templates: template.ParseFiles(template.ParseGlob("views/*")),
}
e.Renderer = t
e.GET("/hello", Hello)
e.Static("/static", "static")
e.GET("/", func(c echo.Context) error {
return c.File("views/index.html")
//return c.String(http.StatusOK, "Hello, World!")
})
e.GET("/test", Hello)
e.File("/abc", "views/index.html")
e.Logger.Fatal(e.Start(":1323"))
}
func Hello(c echo.Context) error {
return c.Render(http.StatusOK, "hello", nil)
}
*/