activity_service.pb.gw.go 7.1 KB

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