What's Changed
As of this release, the Connect protocol supports performing idempotent, side-effect free requests using HTTP GETs. This makes it easier to cache responses in the browser, on your CDN, or in proxies and other middleboxes.
Note
This functionality is only supported when using the Connect protocol—using a Connect client with a Connect server. When usinggrpc-go
clients, orconnect-go
clients configured with theWithGRPC
orWithGRPCWeb
options, all requests will continue to be HTTP POSTs.
To opt into GET support for a given Protobuf RPC, you must mark it as being side-effect free using the MethodOptions.IdempotencyLevel option:
service ElizaService {
rpc Say(stream SayRequest) returns (SayResponse) {
option idempotency_level = NO_SIDE_EFFECTS;
}
}
With this schema change, handlers will automatically support both GET and POST requests for this RPC. However, clients will continue to use POST requests by default, even when GETs are possible. To make clients use GETs for side effect free RPCs, use the WithHTTPGet
option:
client := elizav1connect.NewElizaServiceClient(
http.DefaultClient,
connect.WithHTTPGet(),
)
This functionality is not yet supported by other Connect implementations (including connect-es
), but hang tight! We're working on it. For more information, please check the full documentation.
Enhancements
- Connect HTTP Get support by @jchadwick-buf in #478
- Add APIs to make and handle conditional GETs by @akshayjshah in #494
Bugfixes
Full Changelog: v1.6.0...v1.7.0