FauxRPC is a powerful tool that empowers you to accelerate development and testing by effortlessly generating fake implementations of gRPC, gRPC-Web, Connect, and REST services. If you have a protobuf-based workflow, this tool could help.
Define your protobuf file and start FauxRPC. Now you instantly have a working service to start integrating against! You can use tools like grpcurl, buf curl or even curl.
This is an example protobuf file.
syntax = "proto3";
package examples.basic;
service Greeter {
rpc SayHello(HelloRequest) returns (HelloReply) {
option idempotency_level = NO_SIDE_EFFECTS;
}
rpc WriteHello(HelloRequest) returns (HelloReply) {}
}
message HelloRequest {
string name = 1;
uint32 hello_count = 2;
}
message HelloReply {
string message = 1;
}
$ fauxrpc run --schema greet.proto
FauxRPC (0.2.0 (697fec09ce17947605f1014095691bba43dac2ce) @ 2024-11-16T14:40:32Z; go1.23.3) - 1 services loaded
Listening on http://127.0.0.1:6660
OpenAPI documentation: http://127.0.0.1:6660/fauxrpc/openapi.html
Example Commands:
$ buf curl --http2-prior-knowledge http://127.0.0.1:6660 --list-methods
$ buf curl --http2-prior-knowledge http://127.0.0.1:6660/[METHOD_NAME]
Server started.
Now that you have FauxRPC running, you can make requests to it! Let’s start with grpcurl:
$ grpcurl -plaintext 127.0.0.1:6660 list
examples.basic.Greeter
$ grpcurl -plaintext 127.0.0.1:6660 list examples.basic.Greeter
examples.basic.Greeter.SayHello
examples.basic.Greeter.WriteHello
$ grpcurl -d '{"name": "Kevin"}' -plaintext 127.0.0.1:6660 examples.basic.Greeter/SayHello
{
"message": "Poutine."
}
You can also use buf curl:
$ buf curl --http2-prior-knowledge http://127.0.0.1:6660 --list-methods
examples.basic.Greeter/SayHello
examples.basic.Greeter/WriteHello
$ buf curl -d '{"name": "Kevin"}' --http2-prior-knowledge http://127.0.0.1:6660/examples.basic.Greeter/SayHello
{
"message": "Asymmetrical skateboard."
}
$ buf curl -d '{"name": "Kevin"}' --protocol=grpc --http2-prior-knowledge http://127.0.0.1:6660/examples.basic.Greeter/SayHello
{
"message": "Asymmetrical skateboard."
}
$ buf curl -d '{"name": "Kevin"}' --protocol=grpcweb --http2-prior-knowledge http://127.0.0.1:6660/examples.basic.Greeter/SayHello
{
"message": "Asymmetrical skateboard."
}
And obviously, generated gRPC/gRPC-Web/Connect clients all work as expected as well.
Work independently without relying on fully functional backend services.
Test frontend components in isolation with controlled fake data.
Supports multiple protocols: gRPC, gRPC-Web, Connect, and REST.
Create prototypes and demos quickly without building the full backend. Fake it till you make it.
(go only) Superpower testing Go services by using FauxRPC with Testcontainers.
Test data from FauxRPC will try to automatically follow any protovalidate constraints that are defined.