workspace_service.pb.gw.go 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148
  1. // Code generated by protoc-gen-grpc-gateway. DO NOT EDIT.
  2. // source: api/v1/workspace_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_WorkspaceService_GetWorkspaceProfile_0(ctx context.Context, marshaler runtime.Marshaler, client WorkspaceServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
  33. var (
  34. protoReq GetWorkspaceProfileRequest
  35. metadata runtime.ServerMetadata
  36. )
  37. msg, err := client.GetWorkspaceProfile(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
  38. return msg, metadata, err
  39. }
  40. func local_request_WorkspaceService_GetWorkspaceProfile_0(ctx context.Context, marshaler runtime.Marshaler, server WorkspaceServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
  41. var (
  42. protoReq GetWorkspaceProfileRequest
  43. metadata runtime.ServerMetadata
  44. )
  45. msg, err := server.GetWorkspaceProfile(ctx, &protoReq)
  46. return msg, metadata, err
  47. }
  48. // RegisterWorkspaceServiceHandlerServer registers the http handlers for service WorkspaceService to "mux".
  49. // UnaryRPC :call WorkspaceServiceServer directly.
  50. // StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906.
  51. // Note that using this registration option will cause many gRPC library features to stop working. Consider using RegisterWorkspaceServiceHandlerFromEndpoint instead.
  52. // 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.
  53. func RegisterWorkspaceServiceHandlerServer(ctx context.Context, mux *runtime.ServeMux, server WorkspaceServiceServer) error {
  54. mux.Handle(http.MethodGet, pattern_WorkspaceService_GetWorkspaceProfile_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
  55. ctx, cancel := context.WithCancel(req.Context())
  56. defer cancel()
  57. var stream runtime.ServerTransportStream
  58. ctx = grpc.NewContextWithServerTransportStream(ctx, &stream)
  59. inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
  60. annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/memos.api.v1.WorkspaceService/GetWorkspaceProfile", runtime.WithHTTPPathPattern("/api/v1/workspace/profile"))
  61. if err != nil {
  62. runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
  63. return
  64. }
  65. resp, md, err := local_request_WorkspaceService_GetWorkspaceProfile_0(annotatedContext, inboundMarshaler, server, req, pathParams)
  66. md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer())
  67. annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md)
  68. if err != nil {
  69. runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err)
  70. return
  71. }
  72. forward_WorkspaceService_GetWorkspaceProfile_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
  73. })
  74. return nil
  75. }
  76. // RegisterWorkspaceServiceHandlerFromEndpoint is same as RegisterWorkspaceServiceHandler but
  77. // automatically dials to "endpoint" and closes the connection when "ctx" gets done.
  78. func RegisterWorkspaceServiceHandlerFromEndpoint(ctx context.Context, mux *runtime.ServeMux, endpoint string, opts []grpc.DialOption) (err error) {
  79. conn, err := grpc.NewClient(endpoint, opts...)
  80. if err != nil {
  81. return err
  82. }
  83. defer func() {
  84. if err != nil {
  85. if cerr := conn.Close(); cerr != nil {
  86. grpclog.Errorf("Failed to close conn to %s: %v", endpoint, cerr)
  87. }
  88. return
  89. }
  90. go func() {
  91. <-ctx.Done()
  92. if cerr := conn.Close(); cerr != nil {
  93. grpclog.Errorf("Failed to close conn to %s: %v", endpoint, cerr)
  94. }
  95. }()
  96. }()
  97. return RegisterWorkspaceServiceHandler(ctx, mux, conn)
  98. }
  99. // RegisterWorkspaceServiceHandler registers the http handlers for service WorkspaceService to "mux".
  100. // The handlers forward requests to the grpc endpoint over "conn".
  101. func RegisterWorkspaceServiceHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc.ClientConn) error {
  102. return RegisterWorkspaceServiceHandlerClient(ctx, mux, NewWorkspaceServiceClient(conn))
  103. }
  104. // RegisterWorkspaceServiceHandlerClient registers the http handlers for service WorkspaceService
  105. // to "mux". The handlers forward requests to the grpc endpoint over the given implementation of "WorkspaceServiceClient".
  106. // Note: the gRPC framework executes interceptors within the gRPC handler. If the passed in "WorkspaceServiceClient"
  107. // doesn't go through the normal gRPC flow (creating a gRPC client etc.) then it will be up to the passed in
  108. // "WorkspaceServiceClient" to call the correct interceptors. This client ignores the HTTP middlewares.
  109. func RegisterWorkspaceServiceHandlerClient(ctx context.Context, mux *runtime.ServeMux, client WorkspaceServiceClient) error {
  110. mux.Handle(http.MethodGet, pattern_WorkspaceService_GetWorkspaceProfile_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
  111. ctx, cancel := context.WithCancel(req.Context())
  112. defer cancel()
  113. inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
  114. annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/memos.api.v1.WorkspaceService/GetWorkspaceProfile", runtime.WithHTTPPathPattern("/api/v1/workspace/profile"))
  115. if err != nil {
  116. runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
  117. return
  118. }
  119. resp, md, err := request_WorkspaceService_GetWorkspaceProfile_0(annotatedContext, inboundMarshaler, client, req, pathParams)
  120. annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md)
  121. if err != nil {
  122. runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err)
  123. return
  124. }
  125. forward_WorkspaceService_GetWorkspaceProfile_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
  126. })
  127. return nil
  128. }
  129. var (
  130. pattern_WorkspaceService_GetWorkspaceProfile_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"api", "v1", "workspace", "profile"}, ""))
  131. )
  132. var (
  133. forward_WorkspaceService_GetWorkspaceProfile_0 = runtime.ForwardResponseMessage
  134. )