diff options
| author | Eltrac <hi@guhub.cn> | 2025-11-27 10:36:28 +0800 |
|---|---|---|
| committer | Eltrac <hi@guhub.cn> | 2025-11-27 10:36:28 +0800 |
| commit | 8f614ad595f82d70555e10f014e711b81190be86 (patch) | |
| tree | fc3583cf636e7e469471eac4b903c140fa5e12b1 | |
| parent | a52afde13b4e483e5dd96c7d1a3ace81ce400103 (diff) | |
chore: write tests
| -rw-r--r-- | main.go | 5 | ||||
| -rw-r--r-- | test/main.go | 37 |
2 files changed, 37 insertions, 5 deletions
diff --git a/main.go b/main.go deleted file mode 100644 index e2864ae..0000000 --- a/main.go +++ /dev/null @@ -1,5 +0,0 @@ -package growel - -func main() { - -} diff --git a/test/main.go b/test/main.go new file mode 100644 index 0000000..553456d --- /dev/null +++ b/test/main.go @@ -0,0 +1,37 @@ +package main + +import ( + "fmt" + + "github.com/bigcoke233/growel/v2" +) + +func main() { + api := growel.New() + + api.GET("/hello", func(c *growel.Context) { + c.W.Write([]byte("Hello, World!")) + }) + + api.GET("/", func(c *growel.Context) { + c.W.Write([]byte("This is home.")) + }) + + api.GET("/test", func(c *growel.Context) { + c.W.Write([]byte("testing")) + }) + + api.GET("/test/hello", func(c *growel.Context) { + c.W.Write([]byte("testing hello")) + }) + + api.GET("/test/:uid", func(c *growel.Context) { + c.W.Write([]byte(fmt.Sprintf("Testing from %s", c.Params["uid"]))) + }) + + api.GET("/test/:uid/info/:sid", func(c *growel.Context) { + c.W.Write([]byte(fmt.Sprintf("Testing from %s info %s", c.Params["uid"], c.Params["sid"]))) + }) + + api.Start(":8080") +} |
