markdown_service.pb.gw.go 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351
  1. // Code generated by protoc-gen-grpc-gateway. DO NOT EDIT.
  2. // source: api/v1/markdown_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_MarkdownService_ParseMarkdown_0(ctx context.Context, marshaler runtime.Marshaler, client MarkdownServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
  33. var (
  34. protoReq ParseMarkdownRequest
  35. metadata runtime.ServerMetadata
  36. )
  37. if err := marshaler.NewDecoder(req.Body).Decode(&protoReq); err != nil && !errors.Is(err, io.EOF) {
  38. return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
  39. }
  40. msg, err := client.ParseMarkdown(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
  41. return msg, metadata, err
  42. }
  43. func local_request_MarkdownService_ParseMarkdown_0(ctx context.Context, marshaler runtime.Marshaler, server MarkdownServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
  44. var (
  45. protoReq ParseMarkdownRequest
  46. metadata runtime.ServerMetadata
  47. )
  48. if err := marshaler.NewDecoder(req.Body).Decode(&protoReq); err != nil && !errors.Is(err, io.EOF) {
  49. return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
  50. }
  51. msg, err := server.ParseMarkdown(ctx, &protoReq)
  52. return msg, metadata, err
  53. }
  54. func request_MarkdownService_RestoreMarkdownNodes_0(ctx context.Context, marshaler runtime.Marshaler, client MarkdownServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
  55. var (
  56. protoReq RestoreMarkdownNodesRequest
  57. metadata runtime.ServerMetadata
  58. )
  59. if err := marshaler.NewDecoder(req.Body).Decode(&protoReq); err != nil && !errors.Is(err, io.EOF) {
  60. return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
  61. }
  62. msg, err := client.RestoreMarkdownNodes(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
  63. return msg, metadata, err
  64. }
  65. func local_request_MarkdownService_RestoreMarkdownNodes_0(ctx context.Context, marshaler runtime.Marshaler, server MarkdownServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
  66. var (
  67. protoReq RestoreMarkdownNodesRequest
  68. metadata runtime.ServerMetadata
  69. )
  70. if err := marshaler.NewDecoder(req.Body).Decode(&protoReq); err != nil && !errors.Is(err, io.EOF) {
  71. return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
  72. }
  73. msg, err := server.RestoreMarkdownNodes(ctx, &protoReq)
  74. return msg, metadata, err
  75. }
  76. func request_MarkdownService_StringifyMarkdownNodes_0(ctx context.Context, marshaler runtime.Marshaler, client MarkdownServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
  77. var (
  78. protoReq StringifyMarkdownNodesRequest
  79. metadata runtime.ServerMetadata
  80. )
  81. if err := marshaler.NewDecoder(req.Body).Decode(&protoReq); err != nil && !errors.Is(err, io.EOF) {
  82. return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
  83. }
  84. msg, err := client.StringifyMarkdownNodes(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
  85. return msg, metadata, err
  86. }
  87. func local_request_MarkdownService_StringifyMarkdownNodes_0(ctx context.Context, marshaler runtime.Marshaler, server MarkdownServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
  88. var (
  89. protoReq StringifyMarkdownNodesRequest
  90. metadata runtime.ServerMetadata
  91. )
  92. if err := marshaler.NewDecoder(req.Body).Decode(&protoReq); err != nil && !errors.Is(err, io.EOF) {
  93. return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
  94. }
  95. msg, err := server.StringifyMarkdownNodes(ctx, &protoReq)
  96. return msg, metadata, err
  97. }
  98. var filter_MarkdownService_GetLinkMetadata_0 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)}
  99. func request_MarkdownService_GetLinkMetadata_0(ctx context.Context, marshaler runtime.Marshaler, client MarkdownServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
  100. var (
  101. protoReq GetLinkMetadataRequest
  102. metadata runtime.ServerMetadata
  103. )
  104. if err := req.ParseForm(); err != nil {
  105. return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
  106. }
  107. if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_MarkdownService_GetLinkMetadata_0); err != nil {
  108. return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
  109. }
  110. msg, err := client.GetLinkMetadata(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
  111. return msg, metadata, err
  112. }
  113. func local_request_MarkdownService_GetLinkMetadata_0(ctx context.Context, marshaler runtime.Marshaler, server MarkdownServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
  114. var (
  115. protoReq GetLinkMetadataRequest
  116. metadata runtime.ServerMetadata
  117. )
  118. if err := req.ParseForm(); err != nil {
  119. return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
  120. }
  121. if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_MarkdownService_GetLinkMetadata_0); err != nil {
  122. return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
  123. }
  124. msg, err := server.GetLinkMetadata(ctx, &protoReq)
  125. return msg, metadata, err
  126. }
  127. // RegisterMarkdownServiceHandlerServer registers the http handlers for service MarkdownService to "mux".
  128. // UnaryRPC :call MarkdownServiceServer directly.
  129. // StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906.
  130. // Note that using this registration option will cause many gRPC library features to stop working. Consider using RegisterMarkdownServiceHandlerFromEndpoint instead.
  131. // 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.
  132. func RegisterMarkdownServiceHandlerServer(ctx context.Context, mux *runtime.ServeMux, server MarkdownServiceServer) error {
  133. mux.Handle(http.MethodPost, pattern_MarkdownService_ParseMarkdown_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
  134. ctx, cancel := context.WithCancel(req.Context())
  135. defer cancel()
  136. var stream runtime.ServerTransportStream
  137. ctx = grpc.NewContextWithServerTransportStream(ctx, &stream)
  138. inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
  139. annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/memos.api.v1.MarkdownService/ParseMarkdown", runtime.WithHTTPPathPattern("/api/v1/markdown:parse"))
  140. if err != nil {
  141. runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
  142. return
  143. }
  144. resp, md, err := local_request_MarkdownService_ParseMarkdown_0(annotatedContext, inboundMarshaler, server, req, pathParams)
  145. md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer())
  146. annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md)
  147. if err != nil {
  148. runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err)
  149. return
  150. }
  151. forward_MarkdownService_ParseMarkdown_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
  152. })
  153. mux.Handle(http.MethodPost, pattern_MarkdownService_RestoreMarkdownNodes_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
  154. ctx, cancel := context.WithCancel(req.Context())
  155. defer cancel()
  156. var stream runtime.ServerTransportStream
  157. ctx = grpc.NewContextWithServerTransportStream(ctx, &stream)
  158. inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
  159. annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/memos.api.v1.MarkdownService/RestoreMarkdownNodes", runtime.WithHTTPPathPattern("/api/v1/markdown/node:restore"))
  160. if err != nil {
  161. runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
  162. return
  163. }
  164. resp, md, err := local_request_MarkdownService_RestoreMarkdownNodes_0(annotatedContext, inboundMarshaler, server, req, pathParams)
  165. md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer())
  166. annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md)
  167. if err != nil {
  168. runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err)
  169. return
  170. }
  171. forward_MarkdownService_RestoreMarkdownNodes_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
  172. })
  173. mux.Handle(http.MethodPost, pattern_MarkdownService_StringifyMarkdownNodes_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
  174. ctx, cancel := context.WithCancel(req.Context())
  175. defer cancel()
  176. var stream runtime.ServerTransportStream
  177. ctx = grpc.NewContextWithServerTransportStream(ctx, &stream)
  178. inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
  179. annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/memos.api.v1.MarkdownService/StringifyMarkdownNodes", runtime.WithHTTPPathPattern("/api/v1/markdown/node:stringify"))
  180. if err != nil {
  181. runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
  182. return
  183. }
  184. resp, md, err := local_request_MarkdownService_StringifyMarkdownNodes_0(annotatedContext, inboundMarshaler, server, req, pathParams)
  185. md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer())
  186. annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md)
  187. if err != nil {
  188. runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err)
  189. return
  190. }
  191. forward_MarkdownService_StringifyMarkdownNodes_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
  192. })
  193. mux.Handle(http.MethodGet, pattern_MarkdownService_GetLinkMetadata_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
  194. ctx, cancel := context.WithCancel(req.Context())
  195. defer cancel()
  196. var stream runtime.ServerTransportStream
  197. ctx = grpc.NewContextWithServerTransportStream(ctx, &stream)
  198. inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
  199. annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/memos.api.v1.MarkdownService/GetLinkMetadata", runtime.WithHTTPPathPattern("/api/v1/markdown/link:metadata"))
  200. if err != nil {
  201. runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
  202. return
  203. }
  204. resp, md, err := local_request_MarkdownService_GetLinkMetadata_0(annotatedContext, inboundMarshaler, server, req, pathParams)
  205. md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer())
  206. annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md)
  207. if err != nil {
  208. runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err)
  209. return
  210. }
  211. forward_MarkdownService_GetLinkMetadata_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
  212. })
  213. return nil
  214. }
  215. // RegisterMarkdownServiceHandlerFromEndpoint is same as RegisterMarkdownServiceHandler but
  216. // automatically dials to "endpoint" and closes the connection when "ctx" gets done.
  217. func RegisterMarkdownServiceHandlerFromEndpoint(ctx context.Context, mux *runtime.ServeMux, endpoint string, opts []grpc.DialOption) (err error) {
  218. conn, err := grpc.NewClient(endpoint, opts...)
  219. if err != nil {
  220. return err
  221. }
  222. defer func() {
  223. if err != nil {
  224. if cerr := conn.Close(); cerr != nil {
  225. grpclog.Errorf("Failed to close conn to %s: %v", endpoint, cerr)
  226. }
  227. return
  228. }
  229. go func() {
  230. <-ctx.Done()
  231. if cerr := conn.Close(); cerr != nil {
  232. grpclog.Errorf("Failed to close conn to %s: %v", endpoint, cerr)
  233. }
  234. }()
  235. }()
  236. return RegisterMarkdownServiceHandler(ctx, mux, conn)
  237. }
  238. // RegisterMarkdownServiceHandler registers the http handlers for service MarkdownService to "mux".
  239. // The handlers forward requests to the grpc endpoint over "conn".
  240. func RegisterMarkdownServiceHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc.ClientConn) error {
  241. return RegisterMarkdownServiceHandlerClient(ctx, mux, NewMarkdownServiceClient(conn))
  242. }
  243. // RegisterMarkdownServiceHandlerClient registers the http handlers for service MarkdownService
  244. // to "mux". The handlers forward requests to the grpc endpoint over the given implementation of "MarkdownServiceClient".
  245. // Note: the gRPC framework executes interceptors within the gRPC handler. If the passed in "MarkdownServiceClient"
  246. // doesn't go through the normal gRPC flow (creating a gRPC client etc.) then it will be up to the passed in
  247. // "MarkdownServiceClient" to call the correct interceptors. This client ignores the HTTP middlewares.
  248. func RegisterMarkdownServiceHandlerClient(ctx context.Context, mux *runtime.ServeMux, client MarkdownServiceClient) error {
  249. mux.Handle(http.MethodPost, pattern_MarkdownService_ParseMarkdown_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
  250. ctx, cancel := context.WithCancel(req.Context())
  251. defer cancel()
  252. inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
  253. annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/memos.api.v1.MarkdownService/ParseMarkdown", runtime.WithHTTPPathPattern("/api/v1/markdown:parse"))
  254. if err != nil {
  255. runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
  256. return
  257. }
  258. resp, md, err := request_MarkdownService_ParseMarkdown_0(annotatedContext, inboundMarshaler, client, req, pathParams)
  259. annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md)
  260. if err != nil {
  261. runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err)
  262. return
  263. }
  264. forward_MarkdownService_ParseMarkdown_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
  265. })
  266. mux.Handle(http.MethodPost, pattern_MarkdownService_RestoreMarkdownNodes_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
  267. ctx, cancel := context.WithCancel(req.Context())
  268. defer cancel()
  269. inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
  270. annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/memos.api.v1.MarkdownService/RestoreMarkdownNodes", runtime.WithHTTPPathPattern("/api/v1/markdown/node:restore"))
  271. if err != nil {
  272. runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
  273. return
  274. }
  275. resp, md, err := request_MarkdownService_RestoreMarkdownNodes_0(annotatedContext, inboundMarshaler, client, req, pathParams)
  276. annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md)
  277. if err != nil {
  278. runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err)
  279. return
  280. }
  281. forward_MarkdownService_RestoreMarkdownNodes_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
  282. })
  283. mux.Handle(http.MethodPost, pattern_MarkdownService_StringifyMarkdownNodes_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
  284. ctx, cancel := context.WithCancel(req.Context())
  285. defer cancel()
  286. inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
  287. annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/memos.api.v1.MarkdownService/StringifyMarkdownNodes", runtime.WithHTTPPathPattern("/api/v1/markdown/node:stringify"))
  288. if err != nil {
  289. runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
  290. return
  291. }
  292. resp, md, err := request_MarkdownService_StringifyMarkdownNodes_0(annotatedContext, inboundMarshaler, client, req, pathParams)
  293. annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md)
  294. if err != nil {
  295. runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err)
  296. return
  297. }
  298. forward_MarkdownService_StringifyMarkdownNodes_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
  299. })
  300. mux.Handle(http.MethodGet, pattern_MarkdownService_GetLinkMetadata_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
  301. ctx, cancel := context.WithCancel(req.Context())
  302. defer cancel()
  303. inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
  304. annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/memos.api.v1.MarkdownService/GetLinkMetadata", runtime.WithHTTPPathPattern("/api/v1/markdown/link:metadata"))
  305. if err != nil {
  306. runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
  307. return
  308. }
  309. resp, md, err := request_MarkdownService_GetLinkMetadata_0(annotatedContext, inboundMarshaler, client, req, pathParams)
  310. annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md)
  311. if err != nil {
  312. runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err)
  313. return
  314. }
  315. forward_MarkdownService_GetLinkMetadata_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
  316. })
  317. return nil
  318. }
  319. var (
  320. pattern_MarkdownService_ParseMarkdown_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"api", "v1", "markdown"}, "parse"))
  321. pattern_MarkdownService_RestoreMarkdownNodes_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"api", "v1", "markdown", "node"}, "restore"))
  322. pattern_MarkdownService_StringifyMarkdownNodes_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"api", "v1", "markdown", "node"}, "stringify"))
  323. pattern_MarkdownService_GetLinkMetadata_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"api", "v1", "markdown", "link"}, "metadata"))
  324. )
  325. var (
  326. forward_MarkdownService_ParseMarkdown_0 = runtime.ForwardResponseMessage
  327. forward_MarkdownService_RestoreMarkdownNodes_0 = runtime.ForwardResponseMessage
  328. forward_MarkdownService_StringifyMarkdownNodes_0 = runtime.ForwardResponseMessage
  329. forward_MarkdownService_GetLinkMetadata_0 = runtime.ForwardResponseMessage
  330. )