activity_service.pb.gw.go 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189
  1. // Code generated by protoc-gen-grpc-gateway. DO NOT EDIT.
  2. // source: api/v1/activity_service.proto
  3. /*
  4. Package apiv1 is a reverse proxy.
  5. It translates gRPC into RESTful JSON APIs.
  6. */
  7. package apiv1
  8. import (
  9. "context"
  10. "io"
  11. "net/http"
  12. "github.com/grpc-ecosystem/grpc-gateway/v2/runtime"
  13. "github.com/grpc-ecosystem/grpc-gateway/v2/utilities"
  14. "google.golang.org/grpc"
  15. "google.golang.org/grpc/codes"
  16. "google.golang.org/grpc/grpclog"
  17. "google.golang.org/grpc/metadata"
  18. "google.golang.org/grpc/status"
  19. "google.golang.org/protobuf/proto"
  20. )
  21. // Suppress "imported and not used" errors
  22. var _ codes.Code
  23. var _ io.Reader
  24. var _ status.Status
  25. var _ = runtime.String
  26. var _ = utilities.NewDoubleArray
  27. var _ = metadata.Join
  28. func request_ActivityService_GetActivity_0(ctx context.Context, marshaler runtime.Marshaler, client ActivityServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
  29. var protoReq GetActivityRequest
  30. var metadata runtime.ServerMetadata
  31. var (
  32. val string
  33. ok bool
  34. err error
  35. _ = err
  36. )
  37. val, ok = pathParams["id"]
  38. if !ok {
  39. return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "id")
  40. }
  41. protoReq.Id, err = runtime.Int32(val)
  42. if err != nil {
  43. return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "id", err)
  44. }
  45. msg, err := client.GetActivity(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
  46. return msg, metadata, err
  47. }
  48. func local_request_ActivityService_GetActivity_0(ctx context.Context, marshaler runtime.Marshaler, server ActivityServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
  49. var protoReq GetActivityRequest
  50. var metadata runtime.ServerMetadata
  51. var (
  52. val string
  53. ok bool
  54. err error
  55. _ = err
  56. )
  57. val, ok = pathParams["id"]
  58. if !ok {
  59. return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "id")
  60. }
  61. protoReq.Id, err = runtime.Int32(val)
  62. if err != nil {
  63. return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "id", err)
  64. }
  65. msg, err := server.GetActivity(ctx, &protoReq)
  66. return msg, metadata, err
  67. }
  68. // RegisterActivityServiceHandlerServer registers the http handlers for service ActivityService to "mux".
  69. // UnaryRPC :call ActivityServiceServer directly.
  70. // StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906.
  71. // Note that using this registration option will cause many gRPC library features to stop working. Consider using RegisterActivityServiceHandlerFromEndpoint instead.
  72. func RegisterActivityServiceHandlerServer(ctx context.Context, mux *runtime.ServeMux, server ActivityServiceServer) error {
  73. mux.Handle("GET", pattern_ActivityService_GetActivity_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
  74. ctx, cancel := context.WithCancel(req.Context())
  75. defer cancel()
  76. var stream runtime.ServerTransportStream
  77. ctx = grpc.NewContextWithServerTransportStream(ctx, &stream)
  78. inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
  79. var err error
  80. var annotatedContext context.Context
  81. annotatedContext, err = runtime.AnnotateIncomingContext(ctx, mux, req, "/memos.api.v1.ActivityService/GetActivity", runtime.WithHTTPPathPattern("/api/v1/activities/{id}"))
  82. if err != nil {
  83. runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
  84. return
  85. }
  86. resp, md, err := local_request_ActivityService_GetActivity_0(annotatedContext, inboundMarshaler, server, req, pathParams)
  87. md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer())
  88. annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md)
  89. if err != nil {
  90. runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err)
  91. return
  92. }
  93. forward_ActivityService_GetActivity_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
  94. })
  95. return nil
  96. }
  97. // RegisterActivityServiceHandlerFromEndpoint is same as RegisterActivityServiceHandler but
  98. // automatically dials to "endpoint" and closes the connection when "ctx" gets done.
  99. func RegisterActivityServiceHandlerFromEndpoint(ctx context.Context, mux *runtime.ServeMux, endpoint string, opts []grpc.DialOption) (err error) {
  100. conn, err := grpc.NewClient(endpoint, opts...)
  101. if err != nil {
  102. return err
  103. }
  104. defer func() {
  105. if err != nil {
  106. if cerr := conn.Close(); cerr != nil {
  107. grpclog.Errorf("Failed to close conn to %s: %v", endpoint, cerr)
  108. }
  109. return
  110. }
  111. go func() {
  112. <-ctx.Done()
  113. if cerr := conn.Close(); cerr != nil {
  114. grpclog.Errorf("Failed to close conn to %s: %v", endpoint, cerr)
  115. }
  116. }()
  117. }()
  118. return RegisterActivityServiceHandler(ctx, mux, conn)
  119. }
  120. // RegisterActivityServiceHandler registers the http handlers for service ActivityService to "mux".
  121. // The handlers forward requests to the grpc endpoint over "conn".
  122. func RegisterActivityServiceHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc.ClientConn) error {
  123. return RegisterActivityServiceHandlerClient(ctx, mux, NewActivityServiceClient(conn))
  124. }
  125. // RegisterActivityServiceHandlerClient registers the http handlers for service ActivityService
  126. // to "mux". The handlers forward requests to the grpc endpoint over the given implementation of "ActivityServiceClient".
  127. // Note: the gRPC framework executes interceptors within the gRPC handler. If the passed in "ActivityServiceClient"
  128. // doesn't go through the normal gRPC flow (creating a gRPC client etc.) then it will be up to the passed in
  129. // "ActivityServiceClient" to call the correct interceptors.
  130. func RegisterActivityServiceHandlerClient(ctx context.Context, mux *runtime.ServeMux, client ActivityServiceClient) error {
  131. mux.Handle("GET", pattern_ActivityService_GetActivity_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
  132. ctx, cancel := context.WithCancel(req.Context())
  133. defer cancel()
  134. inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
  135. var err error
  136. var annotatedContext context.Context
  137. annotatedContext, err = runtime.AnnotateContext(ctx, mux, req, "/memos.api.v1.ActivityService/GetActivity", runtime.WithHTTPPathPattern("/api/v1/activities/{id}"))
  138. if err != nil {
  139. runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
  140. return
  141. }
  142. resp, md, err := request_ActivityService_GetActivity_0(annotatedContext, inboundMarshaler, client, req, pathParams)
  143. annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md)
  144. if err != nil {
  145. runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err)
  146. return
  147. }
  148. forward_ActivityService_GetActivity_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
  149. })
  150. return nil
  151. }
  152. var (
  153. pattern_ActivityService_GetActivity_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 1, 0, 4, 1, 5, 3}, []string{"api", "v1", "activities", "id"}, ""))
  154. )
  155. var (
  156. forward_ActivityService_GetActivity_0 = runtime.ForwardResponseMessage
  157. )