chat_http.pb.go 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175
  1. // Code generated by protoc-gen-go-http. DO NOT EDIT.
  2. // versions:
  3. // protoc-gen-go-http v2.0.0
  4. package chat
  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. emptypb "google.golang.org/protobuf/types/known/emptypb"
  13. ioutil "io/ioutil"
  14. time "time"
  15. )
  16. // This is a compile-time assertion to ensure that this generated file
  17. // is compatible with the kratos package it is being compiled against.
  18. var _ = new(context.Context)
  19. var _ = binding.EncodeURL
  20. var _ = ioutil.Discard
  21. var _ = new(time.Time)
  22. var _ = new(reply.SuccessReply)
  23. var _ = new(base.Html)
  24. const _ = http.SupportPackageIsVersion1
  25. type ChatHTTPServer interface {
  26. GetIsRead(context.Context, *common.ChatIsReadInfo) (*emptypb.Empty, error)
  27. GotoRoom(context.Context, *common.GoToRoom) (*emptypb.Empty, error)
  28. Send(context.Context, *common.SendMessageRequest) (*common.SendMessageReply, error)
  29. }
  30. func RegisterChatHTTPServer(s *http.Server, srv ChatHTTPServer) {
  31. r := s.Route("/")
  32. r.POST("/api/chat/send", _Chat_Send0_HTTP_Handler(srv))
  33. r.POST("/api/chat/read", _Chat_GetIsRead0_HTTP_Handler(srv))
  34. r.POST("/api/chat/room/goto", _Chat_GotoRoom0_HTTP_Handler(srv))
  35. }
  36. func _Chat_Send0_HTTP_Handler(srv ChatHTTPServer) func(ctx http.Context) error {
  37. return func(ctx http.Context) error {
  38. var in common.SendMessageRequest
  39. if err := ctx.Bind(&in); err != nil {
  40. return err
  41. }
  42. if err := ctx.BindQuery(&in); err != nil {
  43. return err
  44. }
  45. http.SetOperation(ctx, "/api.chat.Chat/Send")
  46. h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) {
  47. return srv.Send(ctx, req.(*common.SendMessageRequest))
  48. })
  49. out, err := h(ctx, &in)
  50. if err != nil {
  51. return err
  52. }
  53. success := &reply.SuccessReply{
  54. Code: 0,
  55. }
  56. if out != nil {
  57. success.Data = out
  58. }
  59. return ctx.Result(200, success)
  60. }
  61. }
  62. func _Chat_GetIsRead0_HTTP_Handler(srv ChatHTTPServer) func(ctx http.Context) error {
  63. return func(ctx http.Context) error {
  64. var in common.ChatIsReadInfo
  65. if err := ctx.Bind(&in); err != nil {
  66. return err
  67. }
  68. if err := ctx.BindQuery(&in); err != nil {
  69. return err
  70. }
  71. http.SetOperation(ctx, "/api.chat.Chat/GetIsRead")
  72. h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) {
  73. return srv.GetIsRead(ctx, req.(*common.ChatIsReadInfo))
  74. })
  75. out, err := h(ctx, &in)
  76. if err != nil {
  77. return err
  78. }
  79. success := &reply.SuccessReply{
  80. Code: 0,
  81. }
  82. if out != nil {
  83. success.Data = out
  84. }
  85. return ctx.Result(200, success)
  86. }
  87. }
  88. func _Chat_GotoRoom0_HTTP_Handler(srv ChatHTTPServer) func(ctx http.Context) error {
  89. return func(ctx http.Context) error {
  90. var in common.GoToRoom
  91. if err := ctx.Bind(&in); err != nil {
  92. return err
  93. }
  94. if err := ctx.BindQuery(&in); err != nil {
  95. return err
  96. }
  97. http.SetOperation(ctx, "/api.chat.Chat/GotoRoom")
  98. h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) {
  99. return srv.GotoRoom(ctx, req.(*common.GoToRoom))
  100. })
  101. out, err := h(ctx, &in)
  102. if err != nil {
  103. return err
  104. }
  105. success := &reply.SuccessReply{
  106. Code: 0,
  107. }
  108. if out != nil {
  109. success.Data = out
  110. }
  111. return ctx.Result(200, success)
  112. }
  113. }
  114. type ChatHTTPClient interface {
  115. GetIsRead(ctx context.Context, req *common.ChatIsReadInfo, opts ...http.CallOption) (rsp *emptypb.Empty, err error)
  116. GotoRoom(ctx context.Context, req *common.GoToRoom, opts ...http.CallOption) (rsp *emptypb.Empty, err error)
  117. Send(ctx context.Context, req *common.SendMessageRequest, opts ...http.CallOption) (rsp *common.SendMessageReply, err error)
  118. }
  119. type ChatHTTPClientImpl struct {
  120. cc *http.Client
  121. }
  122. func NewChatHTTPClient(client *http.Client) ChatHTTPClient {
  123. return &ChatHTTPClientImpl{client}
  124. }
  125. func (c *ChatHTTPClientImpl) GetIsRead(ctx context.Context, in *common.ChatIsReadInfo, opts ...http.CallOption) (*emptypb.Empty, error) {
  126. var out emptypb.Empty
  127. pattern := "/api/chat/read"
  128. path := binding.EncodeURL(pattern, in, false)
  129. opts = append(opts, http.Operation("/api.chat.Chat/GetIsRead"))
  130. opts = append(opts, http.PathTemplate(pattern))
  131. err := c.cc.Invoke(ctx, "POST", path, in, &out, opts...)
  132. if err != nil {
  133. return nil, err
  134. }
  135. return &out, err
  136. }
  137. func (c *ChatHTTPClientImpl) GotoRoom(ctx context.Context, in *common.GoToRoom, opts ...http.CallOption) (*emptypb.Empty, error) {
  138. var out emptypb.Empty
  139. pattern := "/api/chat/room/goto"
  140. path := binding.EncodeURL(pattern, in, false)
  141. opts = append(opts, http.Operation("/api.chat.Chat/GotoRoom"))
  142. opts = append(opts, http.PathTemplate(pattern))
  143. err := c.cc.Invoke(ctx, "POST", path, in, &out, opts...)
  144. if err != nil {
  145. return nil, err
  146. }
  147. return &out, err
  148. }
  149. func (c *ChatHTTPClientImpl) Send(ctx context.Context, in *common.SendMessageRequest, opts ...http.CallOption) (*common.SendMessageReply, error) {
  150. var out common.SendMessageReply
  151. pattern := "/api/chat/send"
  152. path := binding.EncodeURL(pattern, in, false)
  153. opts = append(opts, http.Operation("/api.chat.Chat/Send"))
  154. opts = append(opts, http.PathTemplate(pattern))
  155. err := c.cc.Invoke(ctx, "POST", path, in, &out, opts...)
  156. if err != nil {
  157. return nil, err
  158. }
  159. return &out, err
  160. }