Skip to content
This repository has been archived by the owner on Nov 14, 2023. It is now read-only.

fix: simplify logic for HTTP/1.1 REST fallback option #54

Merged
merged 2 commits into from
Sep 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
9 changes: 4 additions & 5 deletions src/v1/provisioning_client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,16 +98,15 @@ export class ProvisioningClient {
* API remote host.
* @param {gax.ClientConfig} [options.clientConfig] - Client configuration override.
* Follows the structure of {@link gapicConfig}.
* @param {boolean | "rest"} [options.fallback] - Use HTTP fallback mode.
* Pass "rest" to use HTTP/1.1 REST API instead of gRPC.
* @param {boolean} [options.fallback] - Use HTTP/1.1 REST mode.
* For more information, please check the
* {@link https://github.com/googleapis/gax-nodejs/blob/main/client-libraries.md#http11-rest-api-mode documentation}.
* @param {gax} [gaxInstance]: loaded instance of `google-gax`. Useful if you
* need to avoid loading the default gRPC version and want to use the fallback
* HTTP implementation. Load only fallback version and pass it to the constructor:
* ```
* const gax = require('google-gax/build/src/fallback'); // avoids loading google-gax with gRPC
* const client = new ProvisioningClient({fallback: 'rest'}, gax);
* const client = new ProvisioningClient({fallback: true}, gax);
* ```
*/
constructor(
Expand Down Expand Up @@ -179,7 +178,7 @@ export class ProvisioningClient {
}
if (!opts.fallback) {
clientHeader.push(`grpc/${this._gaxGrpc.grpcVersion}`);
} else if (opts.fallback === 'rest') {
} else {
clientHeader.push(`rest/${this._gaxGrpc.grpcVersion}`);
}
if (opts.libName && opts.libVersion) {
Expand Down Expand Up @@ -238,7 +237,7 @@ export class ProvisioningClient {
auth: this.auth,
grpc: 'grpc' in this._gaxGrpc ? this._gaxGrpc.grpc : undefined,
};
if (opts.fallback === 'rest') {
if (opts.fallback) {
lroOptions.protoJson = protoFilesRoot;
lroOptions.httpRules = [
{
Expand Down
7 changes: 3 additions & 4 deletions src/v1/registry_client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,16 +96,15 @@ export class RegistryClient {
* API remote host.
* @param {gax.ClientConfig} [options.clientConfig] - Client configuration override.
* Follows the structure of {@link gapicConfig}.
* @param {boolean | "rest"} [options.fallback] - Use HTTP fallback mode.
* Pass "rest" to use HTTP/1.1 REST API instead of gRPC.
* @param {boolean} [options.fallback] - Use HTTP/1.1 REST mode.
* For more information, please check the
* {@link https://github.com/googleapis/gax-nodejs/blob/main/client-libraries.md#http11-rest-api-mode documentation}.
* @param {gax} [gaxInstance]: loaded instance of `google-gax`. Useful if you
* need to avoid loading the default gRPC version and want to use the fallback
* HTTP implementation. Load only fallback version and pass it to the constructor:
* ```
* const gax = require('google-gax/build/src/fallback'); // avoids loading google-gax with gRPC
* const client = new RegistryClient({fallback: 'rest'}, gax);
* const client = new RegistryClient({fallback: true}, gax);
* ```
*/
constructor(
Expand Down Expand Up @@ -177,7 +176,7 @@ export class RegistryClient {
}
if (!opts.fallback) {
clientHeader.push(`grpc/${this._gaxGrpc.grpcVersion}`);
} else if (opts.fallback === 'rest') {
} else {
clientHeader.push(`rest/${this._gaxGrpc.grpcVersion}`);
}
if (opts.libName && opts.libVersion) {
Expand Down