main.go 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. package main
  2. //import (
  3. // DEATH "github.com/vrecan/death"
  4. // "go-framework/baize"
  5. // "go-tools/api_binding/http_binding"
  6. // "go-tools/api_binding/http_binding/binding_context"
  7. // "syscall"
  8. //)
  9. //type Hello struct {
  10. // What string `json:"what"`
  11. //}
  12. func main() {
  13. //app, err := baize.NewApplication("10000", WithDB(config))
  14. //if err != nil {
  15. // panic(err)
  16. //}
  17. //
  18. //app.RegisterRouter("root", middlewares...).
  19. // BindRoute(binding, &http_binding.SimpleBindItem[any, map[string]any]{
  20. // Path: "/version",
  21. // ResponseFunc: response.SendMapResponse,
  22. // BusinessFunc: func(c *binding_context.Context, inputModel any) (map[string]any, error) {
  23. // return map[string]any{
  24. // "version": "v1.0.0",
  25. // }, nil
  26. // },
  27. // })
  28. //
  29. //app.RegisterRouter("v1", middlewares...).
  30. // BindPost(binding, &http_binding.SimpleBindItem[Hello, map[string]any]{
  31. // Path: "/hello",
  32. // ResponseFunc: response.SendMapResponse,
  33. // BusinessFunc: func(c *binding_context.Context, inputModel Hello) (map[string]any, error) {
  34. // return map[string]any{
  35. // "version": application.GetVersionService().Version(),
  36. // }, nil
  37. // },
  38. // })
  39. //
  40. //go func() {
  41. // err := app.Start()
  42. // if err != nil {
  43. // panic(err)
  44. // }
  45. //}()
  46. //
  47. //defer func() {
  48. // err := app.Finish()
  49. // if err != nil {
  50. // panic(err)
  51. // }
  52. //}()
  53. //
  54. //death := DEATH.NewDeath(syscall.SIGINT, syscall.SIGTERM)
  55. //_ = death.WaitForDeath()
  56. }