basics_http.pb.go 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174
  1. // Code generated by protoc-gen-go-http. DO NOT EDIT.
  2. // versions:
  3. // protoc-gen-go-http v2.0.0
  4. package basics
  5. import (
  6. context "context"
  7. base "git.ikuban.com/server/base-protobuf/kuban/api/base"
  8. reply "git.ikuban.com/server/kratos-utils/http/reply"
  9. common "git.ikuban.com/server/pw-protobuf/api/common"
  10. http "github.com/go-kratos/kratos/v2/transport/http"
  11. binding "github.com/go-kratos/kratos/v2/transport/http/binding"
  12. ioutil "io/ioutil"
  13. time "time"
  14. )
  15. // This is a compile-time assertion to ensure that this generated file
  16. // is compatible with the kratos package it is being compiled against.
  17. var _ = new(context.Context)
  18. var _ = binding.EncodeURL
  19. var _ = ioutil.Discard
  20. var _ = new(time.Time)
  21. var _ = new(reply.SuccessReply)
  22. var _ = new(base.Html)
  23. const _ = http.SupportPackageIsVersion1
  24. type BasicsHTTPServer interface {
  25. RandomAvatar(context.Context, *common.SexReq) (*RandomAvatarReply, error)
  26. RandomIntroduce(context.Context, *common.SexReq) (*common.RandomIntroduceReply, error)
  27. RandomNickname(context.Context, *common.SexReq) (*RandomNicknameReply, error)
  28. }
  29. func RegisterBasicsHTTPServer(s *http.Server, srv BasicsHTTPServer) {
  30. r := s.Route("/")
  31. r.POST("/api/common/random/nickname", _Basics_RandomNickname0_HTTP_Handler(srv))
  32. r.POST("/api/common/random/avatar", _Basics_RandomAvatar0_HTTP_Handler(srv))
  33. r.POST("/api/common/random/introduce", _Basics_RandomIntroduce0_HTTP_Handler(srv))
  34. }
  35. func _Basics_RandomNickname0_HTTP_Handler(srv BasicsHTTPServer) func(ctx http.Context) error {
  36. return func(ctx http.Context) error {
  37. var in common.SexReq
  38. if err := ctx.Bind(&in); err != nil {
  39. return err
  40. }
  41. if err := ctx.BindQuery(&in); err != nil {
  42. return err
  43. }
  44. http.SetOperation(ctx, "/api.basics.Basics/RandomNickname")
  45. h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) {
  46. return srv.RandomNickname(ctx, req.(*common.SexReq))
  47. })
  48. out, err := h(ctx, &in)
  49. if err != nil {
  50. return err
  51. }
  52. success := &reply.SuccessReply{
  53. Code: 0,
  54. }
  55. if out != nil {
  56. success.Data = out
  57. }
  58. return ctx.Result(200, success)
  59. }
  60. }
  61. func _Basics_RandomAvatar0_HTTP_Handler(srv BasicsHTTPServer) func(ctx http.Context) error {
  62. return func(ctx http.Context) error {
  63. var in common.SexReq
  64. if err := ctx.Bind(&in); err != nil {
  65. return err
  66. }
  67. if err := ctx.BindQuery(&in); err != nil {
  68. return err
  69. }
  70. http.SetOperation(ctx, "/api.basics.Basics/RandomAvatar")
  71. h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) {
  72. return srv.RandomAvatar(ctx, req.(*common.SexReq))
  73. })
  74. out, err := h(ctx, &in)
  75. if err != nil {
  76. return err
  77. }
  78. success := &reply.SuccessReply{
  79. Code: 0,
  80. }
  81. if out != nil {
  82. success.Data = out
  83. }
  84. return ctx.Result(200, success)
  85. }
  86. }
  87. func _Basics_RandomIntroduce0_HTTP_Handler(srv BasicsHTTPServer) func(ctx http.Context) error {
  88. return func(ctx http.Context) error {
  89. var in common.SexReq
  90. if err := ctx.Bind(&in); err != nil {
  91. return err
  92. }
  93. if err := ctx.BindQuery(&in); err != nil {
  94. return err
  95. }
  96. http.SetOperation(ctx, "/api.basics.Basics/RandomIntroduce")
  97. h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) {
  98. return srv.RandomIntroduce(ctx, req.(*common.SexReq))
  99. })
  100. out, err := h(ctx, &in)
  101. if err != nil {
  102. return err
  103. }
  104. success := &reply.SuccessReply{
  105. Code: 0,
  106. }
  107. if out != nil {
  108. success.Data = out
  109. }
  110. return ctx.Result(200, success)
  111. }
  112. }
  113. type BasicsHTTPClient interface {
  114. RandomAvatar(ctx context.Context, req *common.SexReq, opts ...http.CallOption) (rsp *RandomAvatarReply, err error)
  115. RandomIntroduce(ctx context.Context, req *common.SexReq, opts ...http.CallOption) (rsp *common.RandomIntroduceReply, err error)
  116. RandomNickname(ctx context.Context, req *common.SexReq, opts ...http.CallOption) (rsp *RandomNicknameReply, err error)
  117. }
  118. type BasicsHTTPClientImpl struct {
  119. cc *http.Client
  120. }
  121. func NewBasicsHTTPClient(client *http.Client) BasicsHTTPClient {
  122. return &BasicsHTTPClientImpl{client}
  123. }
  124. func (c *BasicsHTTPClientImpl) RandomAvatar(ctx context.Context, in *common.SexReq, opts ...http.CallOption) (*RandomAvatarReply, error) {
  125. var out RandomAvatarReply
  126. pattern := "/api/common/random/avatar"
  127. path := binding.EncodeURL(pattern, in, false)
  128. opts = append(opts, http.Operation("/api.basics.Basics/RandomAvatar"))
  129. opts = append(opts, http.PathTemplate(pattern))
  130. err := c.cc.Invoke(ctx, "POST", path, in, &out, opts...)
  131. if err != nil {
  132. return nil, err
  133. }
  134. return &out, err
  135. }
  136. func (c *BasicsHTTPClientImpl) RandomIntroduce(ctx context.Context, in *common.SexReq, opts ...http.CallOption) (*common.RandomIntroduceReply, error) {
  137. var out common.RandomIntroduceReply
  138. pattern := "/api/common/random/introduce"
  139. path := binding.EncodeURL(pattern, in, false)
  140. opts = append(opts, http.Operation("/api.basics.Basics/RandomIntroduce"))
  141. opts = append(opts, http.PathTemplate(pattern))
  142. err := c.cc.Invoke(ctx, "POST", path, in, &out, opts...)
  143. if err != nil {
  144. return nil, err
  145. }
  146. return &out, err
  147. }
  148. func (c *BasicsHTTPClientImpl) RandomNickname(ctx context.Context, in *common.SexReq, opts ...http.CallOption) (*RandomNicknameReply, error) {
  149. var out RandomNicknameReply
  150. pattern := "/api/common/random/nickname"
  151. path := binding.EncodeURL(pattern, in, false)
  152. opts = append(opts, http.Operation("/api.basics.Basics/RandomNickname"))
  153. opts = append(opts, http.PathTemplate(pattern))
  154. err := c.cc.Invoke(ctx, "POST", path, in, &out, opts...)
  155. if err != nil {
  156. return nil, err
  157. }
  158. return &out, err
  159. }