次の方法で共有


IDownstreamApi.GetForUserAsync Method

Definition

Overloads

GetForUserAsync<TInput,TOutput>(String, TInput, Action<DownstreamApiOptionsReadOnlyHttpMethod>, ClaimsPrincipal, CancellationToken)

Calls, using Get, a downstream API with some input data and returning data. By default the input data is serialized in JSON and the returned data is deserialized from JSON but you can provide your own serializer and your own deserializer in the action you pass-in through the downstreamApiOptionsOverride parameter.

GetForUserAsync<TOutput>(String, Action<DownstreamApiOptionsReadOnlyHttpMethod>, ClaimsPrincipal, CancellationToken)

Calls, using Get, a downstream API returning data. By default the returned data is deserialized from JSON but you can provide your own deserializer in the action you pass-in through the downstreamApiOptionsOverride parameter.

GetForUserAsync<TInput,TOutput>(String, TInput, Action<DownstreamApiOptionsReadOnlyHttpMethod>, ClaimsPrincipal, CancellationToken)

Calls, using Get, a downstream API with some input data and returning data. By default the input data is serialized in JSON and the returned data is deserialized from JSON but you can provide your own serializer and your own deserializer in the action you pass-in through the downstreamApiOptionsOverride parameter.

public System.Threading.Tasks.Task<TOutput?> GetForUserAsync<TInput,TOutput> (string? serviceName, TInput input, Action<Microsoft.Identity.Abstractions.DownstreamApiOptionsReadOnlyHttpMethod>? downstreamApiOptionsOverride = default, System.Security.Claims.ClaimsPrincipal? user = default, System.Threading.CancellationToken cancellationToken = default) where TOutput : class;
abstract member GetForUserAsync : string * 'Input * Action<Microsoft.Identity.Abstractions.DownstreamApiOptionsReadOnlyHttpMethod> * System.Security.Claims.ClaimsPrincipal * System.Threading.CancellationToken -> System.Threading.Tasks.Task<'Output (requires 'Output : null)> (requires 'Output : null)
Public Function GetForUserAsync(Of TInput, TOutput) (serviceName As String, input As TInput, Optional downstreamApiOptionsOverride As Action(Of DownstreamApiOptionsReadOnlyHttpMethod) = Nothing, Optional user As ClaimsPrincipal = Nothing, Optional cancellationToken As CancellationToken = Nothing) As Task(Of TOutput)

Type Parameters

TInput

Generic input type.

TOutput

Generic output type.

Parameters

serviceName
String

Name of the service describing the downstream API. There can be several configuration named sections mapped to a DownstreamApiOptions, each for one downstream API. You can pass-in null, but in that case downstreamApiOptionsOverride needs to be set.

input
TInput

Data sent to the downstream web API, through the body or the HTTP request.

downstreamApiOptionsOverride
Action<DownstreamApiOptionsReadOnlyHttpMethod>

[Optional] Overrides the options proposed in the configuration described by serviceName.

user
ClaimsPrincipal

[Optional] Claims representing a user. This is useful in platforms like Blazor or Azure Signal R, where the HttpContext is not available. In other platforms, the library will find the user from the HttpContext.

cancellationToken
CancellationToken

Returns

Task<TOutput>

The value returned by the downstream web API.

Examples

var result = await _downstreamApi.GetForUserAsync<MyItem, IEnumerable<MyItem>>(
       "MyService",
       myItem,
       options =>
       {
         options.RelativePath = $"api/todolist/{myItem.Id}";
       });

Applies to

GetForUserAsync<TOutput>(String, Action<DownstreamApiOptionsReadOnlyHttpMethod>, ClaimsPrincipal, CancellationToken)

Calls, using Get, a downstream API returning data. By default the returned data is deserialized from JSON but you can provide your own deserializer in the action you pass-in through the downstreamApiOptionsOverride parameter.

public System.Threading.Tasks.Task<TOutput?> GetForUserAsync<TOutput> (string? serviceName, Action<Microsoft.Identity.Abstractions.DownstreamApiOptionsReadOnlyHttpMethod>? downstreamApiOptionsOverride = default, System.Security.Claims.ClaimsPrincipal? user = default, System.Threading.CancellationToken cancellationToken = default) where TOutput : class;
abstract member GetForUserAsync : string * Action<Microsoft.Identity.Abstractions.DownstreamApiOptionsReadOnlyHttpMethod> * System.Security.Claims.ClaimsPrincipal * System.Threading.CancellationToken -> System.Threading.Tasks.Task<'Output (requires 'Output : null)> (requires 'Output : null)
Public Function GetForUserAsync(Of TOutput As Class) (serviceName As String, Optional downstreamApiOptionsOverride As Action(Of DownstreamApiOptionsReadOnlyHttpMethod) = Nothing, Optional user As ClaimsPrincipal = Nothing, Optional cancellationToken As CancellationToken = Nothing) As Task(Of TOutput)

Type Parameters

TOutput

Generic output type.

Parameters

serviceName
String

Name of the service describing the downstream API. There can be several configuration named sections mapped to a DownstreamApiOptions, each for one downstream API. You can pass-in null, but in that case downstreamApiOptionsOverride needs to be set.

downstreamApiOptionsOverride
Action<DownstreamApiOptionsReadOnlyHttpMethod>

[Optional] Overrides the options proposed in the configuration described by serviceName.

user
ClaimsPrincipal

[Optional] Claims representing a user. This is useful in platforms like Blazor or Azure Signal R, where the HttpContext is not available. In other platforms, the library will find the user from the HttpContext.

cancellationToken
CancellationToken

Returns

Task<TOutput>

a Task

Examples

var result = await _downstreamApi.GetForUserAsync<IEnumerable<MyItem>>(
       "MyService",
       options =>
       {
         options.RelativePath = $"api/todolist";
       });

Applies to