-
Notifications
You must be signed in to change notification settings - Fork 26
/
Copy pathyee_test.go
74 lines (63 loc) · 1.45 KB
/
yee_test.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
package yee
import (
"net/http"
"testing"
)
func indexHandle(c Context) (err error) {
return c.JSON(http.StatusOK, "ok")
}
func addRouter(y *Core) {
y.GET("/", indexHandle)
}
func TestYee(t *testing.T) {
y := New()
addRouter(y)
y.Run(":9999")
}
func TestRestApi(t *testing.T) {
y := New()
y.Restful("/", RestfulAPI{
Get: func(c Context) (err error) {
return c.String(http.StatusOK, "updated")
},
Post: func(c Context) (err error) {
return c.String(http.StatusOK, "get it")
},
})
}
func TestDownload(t *testing.T) {
y := New()
y.GET("/", func(c Context) (err error) {
return c.File("args.go")
})
y.Run(":9999")
}
func TestStatic(t *testing.T) {
y := New()
y.Static("/", "dist")
//y.GET("/", func(c Context) error {
// return c.HTMLTpl(http.StatusOK, "./dist/index.html")
//})
y.Run(":9999")
}
////go:embed dist/*
//var f embed.FS
//
////go:embed dist/index.html
//var index string
//func TestPack(t *testing.T) {
// y := New()
// y.Pack("/front", f, "dist")
// y.GET("/", func(c Context) error {
// return c.HTML(http.StatusOK, index)
// })
// y.Run(":9999")
//}
const ver = `alt-svc: h3=":443"; ma=2592000,h3-29=":443"; ma=2592000,h3-Q050=":443"; ma=2592000,h3-Q046=":443"; ma=2592000,h3-Q043=":443"; ma=2592000,quic=":443"; ma=2592000; v="46,43"`
func TestH3(t *testing.T) {
y := New()
y.GET("/", func(c Context) (err error) {
return c.JSON(http.StatusOK, "hello")
})
y.RunH3(":443", "henry.com+4.pem", "henry.com+4-key.pem")
}