captcha.bm.go 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. // Code generated by protoc-gen-bm v0.1, DO NOT EDIT.
  2. // source: api/http/v1/captcha.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. api/http/v1/captcha.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. // =================
  20. // Captcha Interface
  21. // =================
  22. // captcha 相关服务
  23. type Captcha interface {
  24. // 创建验证码 `midware:"auth"`
  25. Create(ctx context.Context, req *CreateCaptchaReq) (resp *CreateCaptchaResp, err error)
  26. // 校验接口 `midware:"auth" method:"POST"`
  27. Verify(ctx context.Context, req *VerifyReq) (resp *VerifyResp, err error)
  28. }
  29. var v1CaptchaSvc Captcha
  30. // @params CreateCaptchaReq
  31. // @router GET /xlive/web-room/v1/captcha/create
  32. // @response CreateCaptchaResp
  33. func captchaCreate(c *bm.Context) {
  34. p := new(CreateCaptchaReq)
  35. if err := c.BindWith(p, binding.Default(c.Request.Method, c.Request.Header.Get("Content-Type"))); err != nil {
  36. return
  37. }
  38. resp, err := v1CaptchaSvc.Create(c, p)
  39. c.JSON(resp, err)
  40. }
  41. // @params VerifyReq
  42. // @router POST /xlive/web-room/v1/captcha/verify
  43. // @response VerifyResp
  44. func captchaVerify(c *bm.Context) {
  45. p := new(VerifyReq)
  46. if err := c.BindWith(p, binding.Default(c.Request.Method, c.Request.Header.Get("Content-Type"))); err != nil {
  47. return
  48. }
  49. resp, err := v1CaptchaSvc.Verify(c, p)
  50. c.JSON(resp, err)
  51. }
  52. // RegisterV1CaptchaService Register the blademaster route with middleware map
  53. // midMap is the middleware map, the key is defined in proto
  54. func RegisterV1CaptchaService(e *bm.Engine, svc Captcha, midMap map[string]bm.HandlerFunc) {
  55. auth := midMap["auth"]
  56. v1CaptchaSvc = svc
  57. e.GET("/xlive/web-room/v1/captcha/create", auth, captchaCreate)
  58. e.POST("/xlive/web-room/v1/captcha/verify", auth, captchaVerify)
  59. }