{"id":26796424,"url":"https://github.com/protobuf-x/protoc-gen-spring-webflux","last_synced_at":"2025-04-22T19:57:56.087Z","repository":{"id":57734539,"uuid":"205694539","full_name":"protobuf-x/protoc-gen-spring-webflux","owner":"protobuf-x","description":"gRPC to JSON proxy generator protoc plugin for Spring WebFlux","archived":false,"fork":false,"pushed_at":"2024-08-18T14:12:32.000Z","size":2603,"stargazers_count":10,"open_issues_count":3,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-29T18:18:34.542Z","etag":null,"topics":["grpc","protobuf","protocol-buffers","spring","springframework"],"latest_commit_sha":null,"homepage":"","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/protobuf-x.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-09-01T15:18:30.000Z","updated_at":"2024-09-11T16:56:40.000Z","dependencies_parsed_at":"2024-12-30T12:03:24.846Z","dependency_job_id":"38f30841-9c78-49b8-802b-9dd96e972932","html_url":"https://github.com/protobuf-x/protoc-gen-spring-webflux","commit_stats":null,"previous_names":[],"tags_count":18,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/protobuf-x%2Fprotoc-gen-spring-webflux","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/protobuf-x%2Fprotoc-gen-spring-webflux/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/protobuf-x%2Fprotoc-gen-spring-webflux/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/protobuf-x%2Fprotoc-gen-spring-webflux/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/protobuf-x","download_url":"https://codeload.github.com/protobuf-x/protoc-gen-spring-webflux/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250315961,"owners_count":21410473,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["grpc","protobuf","protocol-buffers","spring","springframework"],"created_at":"2025-03-29T18:18:40.345Z","updated_at":"2025-04-22T19:57:56.061Z","avatar_url":"https://github.com/protobuf-x.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"# protoc-gen-spring-webflux\ngRPC to JSON handler generator protoc plugin for Spring WebFlux inspired by [grpc-gateway](https://github.com/grpc-ecosystem/grpc-gateway).\n\nThe protoc-gen-spring-webflux is a plugin of the Google protocol buffers compiler\n[protoc](https://github.com/protocolbuffers/protobuf).\nIt reads protobuf service definitions and generates Spring WebFlux HTTP server classes which\ntranslates RESTful HTTP API into gRPC. This server is generated according to the [`google.api.http`](https://github.com/googleapis/googleapis/blob/master/google/api/http.proto#L46) annotations in your service definitions.\n\nUses an external HTTP server separately from the gRPC server to convert Http requests to gRPC calls.\n![image](https://user-images.githubusercontent.com/5003722/71714336-cbd1b100-2e50-11ea-84ea-791e6f8b3aee.png)\n\n## Usage\n\n1. Define your [gRPC](https://grpc.io/docs/) service using protocol buffers.\n\n```protoc:example.proto\nsyntax = \"proto3\";\n\npackage example.demo;\n\n// messages...\n\nservice EchoService {\n\n    rpc GetEcho(EchoRequest) returns (EchoResponse) {\n    }\n\n    rpc CreateEcho(CreateEchoRequest) returns (CreateEchoResponse) {\n    }\n}\n```\n2. Add a [`google.api.http`](https://github.com/googleapis/googleapis/blob/master/google/api/http.proto#L46) annotation to your .proto file for HTTP API.\n\n```diff\nsyntax = \"proto3\";\n\npackage example.demo;\n+import \"google/api/annotations.proto\";\n\n// messages...\n\nservice EchoService {\n\n    rpc GetEcho(EchoRequest) returns (EchoResponse) {\n+        option (google.api.http) = {\n+            get: \"/echo/{echo}\"\n+        };\n    }\n\n    rpc CreateEcho(CreateEchoRequest) returns (CreateEchoResponse) {\n+        option (google.api.http) = {\n+              post: \"/echo\"\n+              body: \"*\"\n+        };\n    }\n}\n```\n\n3. Generate routing handler class using `protoc-gen-spring-webflux`\n\n3-a. Use protoc plugin on Linux or OSX\n\n* When building in a Linux or OSX environment, build with the protoc plugin.\n\n```diff\n# build.gradle\n\nprotobuf {\n    protoc {\n        // ...\n    }\n\n    plugins {\n        // ...\n+       webflux {\n+           artifact = 'io.github.protobuf-x:protoc-gen-spring-webflux:${PROTOC_GEN_SPRING_WEBFLUX_VERSION}'\n+       }\n    }\n\n    generateProtoTasks {\n        all()*.plugins {\n            // ...\n+           webflux {}\n        }\n    }\n}\n```\n\n3-b. Use protoc command\n\n* Since the protobuf plugin for windows is not supported, please execute the protoc command if you need to build on windows.\n\n```bash\nprotoc -I. \\\n    --spring-webflux_out=. \\\n     example.proto\n```\n\nDownload the latest binaries from Maven Central Repository.\n\n[![Maven Central](https://img.shields.io/maven-central/v/io.github.protobuf-x/protoc-gen-spring-webflux.svg?label=Maven%20Central)](https://search.maven.org/search?q=g:%22io.github.protobuf-x%22%20AND%20a:%22protoc-gen-spring-webflux%22)\n\n4. Write an routing of the Spring WebFlux `Handler` server.\n\n```java:HandlerServerConfg.java\n@Configuration\nclass HandlerServerConfg {\n    @Bean\n    ExampleHandlers.EchoServiceHandler exampleHandlers() {\n        ManagedChannel channel = ManagedChannelBuilder.forAddress(/*...*/)\n                .usePlaintext()\n                .build();\n        EchoServiceGrpc.EchoServiceStub stub = EchoServiceGrpc.newStub(channel);\n\n        // ExampleHandlers is a class generated by protoc-gen-spring-webflux\n        return EchoServiceRest.newGrpcProxyBuilder()\n                .setStub(stub)\n                .setIncludeHeaders(Collections.singletonList(\"Authorization\"))\n                .build();\n    }\n\n    @Bean\n    RouterFunction\u003cServerResponse\u003e routing(ExampleHandlers.EchoServiceHandler handler) {\n        return RouterFunctions.route()\n                // Use the handleAll method to route everything to the generated Handler.\n                .add(handler.allRoutes())\n                // Handler can be routed individually by using the generated method.\n                .GET(\"/echo/{id}\", handler::getEcho)\n                .POST(\"/echo\", handler::createEcho)\n                .build();\n    }\n}\n```\n\n## Missing Features Shortlist\n* Streams not supported.\n* Custom patterns not supported.\n* Variables not supported.\n* Not supporting * and ** in path.\n\n\n## License\n(The MIT License)\n\nCopyright (c) 2020 @disc99\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fprotobuf-x%2Fprotoc-gen-spring-webflux","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fprotobuf-x%2Fprotoc-gen-spring-webflux","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fprotobuf-x%2Fprotoc-gen-spring-webflux/lists"}