feat(build): support adding attributes to clients and servers (#684)
This commit is contained in:
@@ -15,6 +15,14 @@ fn main() {
|
||||
|
||||
tonic_build::compile_protos("proto/echo/echo.proto").unwrap();
|
||||
|
||||
tonic_build::configure()
|
||||
.server_mod_attribute("attrs", "#[cfg(feature = \"server\")]")
|
||||
.server_attribute("Echo", "#[derive(PartialEq)]")
|
||||
.client_mod_attribute("attrs", "#[cfg(feature = \"client\")]")
|
||||
.client_attribute("Echo", "#[derive(PartialEq)]")
|
||||
.compile(&["proto/attrs/attrs.proto"], &["proto"])
|
||||
.unwrap();
|
||||
|
||||
tonic_build::configure()
|
||||
.build_server(false)
|
||||
.compile(
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
syntax = "proto3";
|
||||
|
||||
package attrs;
|
||||
|
||||
// EchoRequest is the request for echo.
|
||||
message EchoRequest {
|
||||
string message = 1;
|
||||
}
|
||||
|
||||
// EchoResponse is the response for echo.
|
||||
message EchoResponse {
|
||||
string message = 1;
|
||||
}
|
||||
|
||||
// Echo is the echo service.
|
||||
service Echo {
|
||||
// UnaryEcho is unary echo.
|
||||
rpc UnaryEcho(EchoRequest) returns (EchoResponse) {}
|
||||
}
|
||||
Reference in New Issue
Block a user