feat: make default options platform aware

This commit is contained in:
Ricardo Durao 2025-05-26 11:01:14 +01:00
parent d297a29cb7
commit a6f6e986ea
No known key found for this signature in database
GPG Key ID: 3F140739C3ACE3BF
4 changed files with 65 additions and 1 deletions

View File

@ -0,0 +1,17 @@
// Copyright (c) 2018, the gRPC project authors. Please see the AUTHORS file
// for details. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
export 'call_options_grpc.dart'
if (dart.library.js_interop) 'call_options_grpcweb.dart';

View File

@ -0,0 +1,23 @@
// Copyright (c) 2018, the gRPC project authors. Please see the AUTHORS file
// for details. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
import '../../../grpc.dart';
///
/// Call options for gRPC.
///
CallOptions callOptions() {
return CallOptions();
}

View File

@ -0,0 +1,23 @@
// Copyright (c) 2018, the gRPC project authors. Please see the AUTHORS file
// for details. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
import '../../../grpc_web.dart';
///
/// Call options for gRPC-web.
///
CallOptions callOptions() {
return WebCallOptions(withCredentials: true);
}

View File

@ -14,6 +14,7 @@
// limitations under the License.
import 'call.dart';
import 'call_options/call_options.dart';
import 'channel.dart';
import 'common.dart';
import 'interceptor.dart';
@ -28,7 +29,7 @@ class Client {
/// Interceptors will be applied in direct order before making a request.
Client(this._channel,
{CallOptions? options, Iterable<ClientInterceptor>? interceptors})
: _options = options ?? CallOptions(),
: _options = options ?? callOptions(),
_interceptors = List.unmodifiable(interceptors ?? Iterable.empty());
@Deprecated(r'''This method does not invoke interceptors and is superseded