feat: bootstrap reusable GoOmni framework
This commit is contained in:
20
examples/basic/main.go
Normal file
20
examples/basic/main.go
Normal file
@@ -0,0 +1,20 @@
|
||||
package main
|
||||
|
||||
import "git.yuntuo.hk/k2safe/go-omni"
|
||||
|
||||
func main() {
|
||||
app := omni.New(omni.WithLogger(true))
|
||||
|
||||
app.GET("/health", func(ctx *omni.Context) error {
|
||||
return ctx.OK(map[string]string{"status": "ok"})
|
||||
})
|
||||
|
||||
api := app.Group("/api")
|
||||
api.GET("/users/:id", func(ctx *omni.Context) error {
|
||||
return ctx.OK(map[string]string{
|
||||
"id": ctx.Param("id"),
|
||||
})
|
||||
})
|
||||
|
||||
_ = app.Run(":8080")
|
||||
}
|
||||
Reference in New Issue
Block a user