generated from datewu/project-lib
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
38 lines (34 loc) · 901 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
package main
import (
"fmt"
"net/http"
"github.com/datewu/gtea/handler"
"github.com/datewu/gtea/handler/static"
"github.com/datewu/gtea/router"
)
func main() {
conf := &router.Config{Debug: true}
r := router.NewRouter(conf)
r.Get("/ok", handler.HealthCheck)
r.Get("/ok/good", handler.HealthCheck)
r.Get("/ok/bye", handler.HealthCheck)
r.Get("/ok/bye/lala", handler.HealthCheck)
r.Get("/ok/bye/lala/a/b/c/d/e/f/z", handler.HealthCheck)
r.Post("/ok", handler.HealthCheck)
r.Put("/ok", handler.HealthCheck)
r.Delete("/ok", handler.HealthCheck)
r.Static("/abc", "../../")
r.Static("/", "../../../../..")
fs := static.FS{
NoDir: true,
TryFile: []string{},
Root: "/Users/r/repo/gtea/",
}
r.ServeFS("/test/fs", fs)
srv := &http.Server{
Addr: ":8090",
Handler: r.Handler(),
}
fmt.Println("listen on:", srv.Addr)
fmt.Println("start serve", srv.ListenAndServe())
}