Skip to content

begonia-org/begonia

Repository files navigation

Begonia

Go Report Card codecov Go

English | 中文

Begonia is an HTTP to gRPC reverse proxy server, which registers services defined by `gRPC-gateway` to the gateway based on the descriptor_set_out generated by protoc, thereby implementing reverse proxy functionality. The HTTP service follows the RESTful standard to handle HTTP requests and forwards RESTful requests to gRPC services.

Features

Support

  • Compatible with all gRPC-gateway functionality features.
  • All gRPC request methods and their parameter formats can be requested and forwarded through HTTP 1.1.
  • Forwards gRPC bi-directional streaming service requests based on WebSockets.
  • Forwards server-side streaming responses based on the SSE (Server-Side-Event) protocol.
  • Forwards gRPC client streaming requests based on a custom application/begonia-client-stream request type.
  • Allows requests with application/x-www-form-urlencoded and multipart/form-data parameter formats.
  • Rich built-in middleware, such as APIKEY verification, AKSK verification, and go-playground/validator for parameter validation middleware.parameter verification middleware
  • Dynamic registration, updating, and deletion of gRPC service routes based on the protoc descriptor_set_out.

Getting Started

Installation

git clone https://github.com/begonia-org/begonia.git
cd begonia && make install

Define proto

Refer to example/example.proto

Generate Descriptor Set

protoc --descriptor_set_out=example.pb --include_imports --proto_path=./ example.proto

Start the Gateway Service

1. Build the runtime environment

docker compose up -d

2. Initialize the database

begonia init -e dev

3. Start the service

begonia start -e dev

4. Register the service

go run . endpoint add -n "example" -d /data/work/begonia-org/begonia/example/example.pb -p 127.0.0.1:1949 -p 127.0.0.1:2024

5. Test request service

curl -vvv http://127.0.0.1:12138/api/v1/example/hello

License

Apache License2.0 © geebytes

Contribution

Feel free to PR and raise issues.

Special thanks to

Thanks to the following projects for providing inspiration and reference:

  • gRPC-gateway - Begonia gateway's routing management references and incorporates some code from gRPC-gateway.
  • Kratos - Begonia's gRPC traffic proxy and forwarding functionality reference and incorporate some code from the Kratos project.

Releases

No releases published

Packages

No packages published