main.go 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  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", baize.NewDBPersistence())
  14. //if err != nil {
  15. // panic(err)
  16. //}
  17. //
  18. //app.AddRouter("root", middlewares...).
  19. // GetRouter("root").
  20. // BindRoute(binding, &http_binding.SimpleBindItem[any, map[string]any]{
  21. // Path: "/version",
  22. // ResponseFunc: response.SendMapResponse,
  23. // BusinessFunc: func(c *binding_context.Context, inputModel any) (map[string]any, error) {
  24. // return map[string]any{
  25. // "version": "v1.0.0",
  26. // }, nil
  27. // },
  28. // })
  29. //
  30. //app.AddRouter("v1", middlewares...).
  31. // GetRouter("v1").
  32. // BindPost(binding, &http_binding.SimpleBindItem[Hello, map[string]any]{
  33. // Path: "/hello",
  34. // ResponseFunc: response.SendMapResponse,
  35. // BusinessFunc: func(c *binding_context.Context, inputModel Hello) (map[string]any, error) {
  36. // return map[string]any{
  37. // "version": application.GetVersionService().Version(),
  38. // }, nil
  39. // },
  40. // })
  41. //
  42. //go func() {
  43. // err := app.Start()
  44. // if err != nil {
  45. // panic(err)
  46. // }
  47. //}()
  48. //
  49. //defer func() {
  50. // err := app.Finish()
  51. // if err != nil {
  52. // panic(err)
  53. // }
  54. //}()
  55. //
  56. //death := DEATH.NewDeath(syscall.SIGINT, syscall.SIGTERM)
  57. //_ = death.WaitForDeath()
  58. }