| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950 |
- package main
- import (
- "git.sxidc.com/go-framework/baize"
- "git.sxidc.com/go-framework/baize/application"
- DEATH "github.com/vrecan/death"
- "syscall"
- )
- type Hello struct {
- What string `json:"what"`
- }
- func main() {
- app := baize.NewApplication(application.Config{
- ApiConfig: application.ApiConfig{
- UrlPrefix: "test",
- Port: "10000",
- },
- })
- versionedRouter := app.Api().PrefixRouter().RegisterVersionedRouter("v1")
- binding.GetBind(versionedRouter, &binding.SimpleBindItem[any, map[string]any]{
- Path: "/version",
- ResponseFunc: response.SendMapResponse,
- BusinessFunc: func(c *binding_context.Context, inputModel any) (map[string]any, error) {
- return map[string]any{
- "version": "v1.0.0",
- }, nil
- },
- })
- go func() {
- err := app.Start()
- if err != nil {
- panic(err)
- }
- }()
- defer func() {
- err := app.Finish()
- if err != nil {
- panic(err)
- }
- }()
- death := DEATH.NewDeath(syscall.SIGINT, syscall.SIGTERM)
- _ = death.WaitForDeath()
- }
|