demo.bm.go 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166
  1. // Code generated by protoc-gen-bm v0.1, DO NOT EDIT.
  2. // source: demo.proto
  3. /*
  4. Package v1 is a generated blademaster stub package.
  5. This code was generated with go-common/app/tool/bmgen/protoc-gen-bm v0.1.
  6. It is generated from these files:
  7. demo.proto
  8. */
  9. package v1
  10. import (
  11. "context"
  12. bm "go-common/library/net/http/blademaster"
  13. "go-common/library/net/http/blademaster/binding"
  14. )
  15. // to suppressed 'imported but not used warning'
  16. var _ *bm.Context
  17. var _ context.Context
  18. var _ binding.StructValidator
  19. var PathFooUnameByUid = "/xlive/demo/v1/foo/uname_by_uid_custom_route"
  20. var PathFooGetInfo = "/live.livedemo.v1.Foo/get_info"
  21. var PathFooUnameByUid3 = "/live.livedemo.v1.Foo/uname_by_uid3"
  22. var PathFooUnameByUid4 = "/live.livedemo.v1.Foo/uname_by_uid4"
  23. var PathFooGetDynamic = "/live.livedemo.v1.Foo/get_dynamic"
  24. var PathFooNointerface = "/live.livedemo.v1.Foo/nointerface"
  25. var PathFoo2Hello = "/live.livedemo.v1.Foo2/hello"
  26. // =============
  27. // Foo Interface
  28. // =============
  29. // Foo 相关服务
  30. type FooBMServer interface {
  31. // 根据uid得到uname
  32. // `method:"post" midware:"auth,verify"`
  33. //
  34. // 这是详细说明
  35. UnameByUid(ctx context.Context, req *Bar1Req) (resp *Bar1Resp, err error)
  36. // 获取房间信息
  37. // `midware:"guest"`
  38. GetInfo(ctx context.Context, req *GetInfoReq) (resp *GetInfoResp, err error)
  39. // 根据uid得到uname v3
  40. UnameByUid3(ctx context.Context, req *Bar1Req) (resp *Bar1Resp, err error)
  41. // test comment
  42. // `internal:"true"`
  43. UnameByUid4(ctx context.Context, req *Bar1Req) (resp *Bar1Resp, err error)
  44. // `dynamic_resp:"true"`
  45. GetDynamic(ctx context.Context, req *Bar1Req) (resp interface{}, err error)
  46. }
  47. var v1FooSvc FooBMServer
  48. func fooUnameByUid(c *bm.Context) {
  49. p := new(Bar1Req)
  50. if err := c.BindWith(p, binding.Default(c.Request.Method, c.Request.Header.Get("Content-Type"))); err != nil {
  51. return
  52. }
  53. resp, err := v1FooSvc.UnameByUid(c, p)
  54. c.JSON(resp, err)
  55. }
  56. func fooGetInfo(c *bm.Context) {
  57. p := new(GetInfoReq)
  58. if err := c.BindWith(p, binding.Default(c.Request.Method, c.Request.Header.Get("Content-Type"))); err != nil {
  59. return
  60. }
  61. resp, err := v1FooSvc.GetInfo(c, p)
  62. c.JSON(resp, err)
  63. }
  64. func fooUnameByUid3(c *bm.Context) {
  65. p := new(Bar1Req)
  66. if err := c.BindWith(p, binding.Default(c.Request.Method, c.Request.Header.Get("Content-Type"))); err != nil {
  67. return
  68. }
  69. resp, err := v1FooSvc.UnameByUid3(c, p)
  70. c.JSON(resp, err)
  71. }
  72. func fooUnameByUid4(c *bm.Context) {
  73. p := new(Bar1Req)
  74. if err := c.BindWith(p, binding.Default(c.Request.Method, c.Request.Header.Get("Content-Type"))); err != nil {
  75. return
  76. }
  77. resp, err := v1FooSvc.UnameByUid4(c, p)
  78. c.JSON(resp, err)
  79. }
  80. func fooGetDynamic(c *bm.Context) {
  81. p := new(Bar1Req)
  82. if err := c.BindWith(p, binding.Default(c.Request.Method, c.Request.Header.Get("Content-Type"))); err != nil {
  83. return
  84. }
  85. resp, err := v1FooSvc.GetDynamic(c, p)
  86. c.JSON(resp, err)
  87. }
  88. // RegisterV1FooService Register the blademaster route with middleware map
  89. // midMap is the middleware map, the key is defined in proto
  90. func RegisterV1FooService(e *bm.Engine, svc FooBMServer, midMap map[string]bm.HandlerFunc) {
  91. auth := midMap["auth"]
  92. guest := midMap["guest"]
  93. verify := midMap["verify"]
  94. v1FooSvc = svc
  95. e.GET("/xlive/demo/v1/foo/uname_by_uid_custom_route", auth, verify, fooUnameByUid)
  96. e.GET("/xlive/live-demo/v1/foo/get_info", guest, fooGetInfo)
  97. e.GET("/xlive/live-demo/v1/foo/uname_by_uid3", fooUnameByUid3)
  98. e.GET("/xlive/internal/live-demo/v1/foo/uname_by_uid4", fooUnameByUid4)
  99. e.GET("/xlive/live-demo/v1/foo/get_dynamic", fooGetDynamic)
  100. }
  101. // RegisterFooBMServer Register the blademaster route
  102. func RegisterFooBMServer(e *bm.Engine, server FooBMServer) {
  103. e.GET("/xlive/demo/v1/foo/uname_by_uid_custom_route", fooUnameByUid)
  104. e.GET("/live.livedemo.v1.Foo/get_info", fooGetInfo)
  105. e.GET("/live.livedemo.v1.Foo/uname_by_uid3", fooUnameByUid3)
  106. e.GET("/live.livedemo.v1.Foo/uname_by_uid4", fooUnameByUid4)
  107. e.GET("/live.livedemo.v1.Foo/get_dynamic", fooGetDynamic)
  108. }
  109. // ==============
  110. // Foo2 Interface
  111. // ==============
  112. type Foo2BMServer interface {
  113. Hello(ctx context.Context, req *Bar1Req) (resp *Bar1Resp, err error)
  114. }
  115. var v1Foo2Svc Foo2BMServer
  116. func foo2Hello(c *bm.Context) {
  117. p := new(Bar1Req)
  118. if err := c.BindWith(p, binding.Default(c.Request.Method, c.Request.Header.Get("Content-Type"))); err != nil {
  119. return
  120. }
  121. resp, err := v1Foo2Svc.Hello(c, p)
  122. c.JSON(resp, err)
  123. }
  124. // RegisterV1Foo2Service Register the blademaster route with middleware map
  125. // midMap is the middleware map, the key is defined in proto
  126. func RegisterV1Foo2Service(e *bm.Engine, svc Foo2BMServer, midMap map[string]bm.HandlerFunc) {
  127. v1Foo2Svc = svc
  128. e.GET("/xlive/live-demo/v1/foo2/hello", foo2Hello)
  129. }
  130. // RegisterFoo2BMServer Register the blademaster route
  131. func RegisterFoo2BMServer(e *bm.Engine, server Foo2BMServer) {
  132. e.GET("/live.livedemo.v1.Foo2/hello", foo2Hello)
  133. }