Skip to content

Commit

Permalink
add async to CallWebApiAsync (#358)
Browse files Browse the repository at this point in the history
  • Loading branch information
jennyf19 authored Jul 23, 2020
1 parent a141b88 commit 32e8caa
Show file tree
Hide file tree
Showing 12 changed files with 18 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,6 @@ else

protected override async Task OnInitializedAsync()
{
apiResult = await downstreamAPI.CallWebApi();
apiResult = await downstreamAPI.CallWebApiAsync();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ namespace BlazorServerWeb_CSharp
{
public interface IDownstreamWebApi
{
Task<string> CallWebApi(string relativeEndpoint = "", string[] requiredScopes = null);
Task<string> CallWebApiAsync(string relativeEndpoint = "", string[] requiredScopes = null);
}

public static class DownstreamWebApiExtensions
Expand Down Expand Up @@ -46,7 +46,7 @@ public DownstreamWebApi(
/// not specified, uses scopes from the configuration</param>
/// <param name="relativeEndpoint">Endpoint relative to the CalledApiUrl configuration</param>
/// <returns>A JSON string representing the result of calling the Web API</returns>
public async Task<string> CallWebApi(string relativeEndpoint = "", string[] requiredScopes = null)
public async Task<string> CallWebApiAsync(string relativeEndpoint = "", string[] requiredScopes = null)
{
string[] scopes = requiredScopes ?? _configuration["CalledApi:CalledApiScopes"]?.Split(' ');
string apiUrl = (_configuration["CalledApi:CalledApiUrl"] as string)?.TrimEnd('/') + $"/{relativeEndpoint}";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public async Task<IEnumerable<WeatherForecast>> Get()
{
HttpContext.VerifyUserHasAnyAcceptedScope(scopeRequiredByApi);

string downstreamApiResult = await _downstreamWebApi.CallWebApi();
string downstreamApiResult = await _downstreamWebApi.CallWebApiAsync();

var rng = new Random();
return Enumerable.Range(1, 5).Select(index => new WeatherForecast
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ namespace ComponentsWebAssembly_CSharp.Server
{
public interface IDownstreamWebApi
{
Task<string> CallWebApi(string relativeEndpoint = "", string[] requiredScopes = null);
Task<string> CallWebApiAsync(string relativeEndpoint = "", string[] requiredScopes = null);
}

public static class DownstreamWebApiExtensions
Expand Down Expand Up @@ -46,7 +46,7 @@ public DownstreamWebApi(
/// not specified, uses scopes from the configuration</param>
/// <param name="relativeEndpoint">Endpoint relative to the CalledApiUrl configuration</param>
/// <returns>A JSON string representing the result of calling the Web API</returns>
public async Task<string> CallWebApi(string relativeEndpoint = "", string[] requiredScopes = null)
public async Task<string> CallWebApiAsync(string relativeEndpoint = "", string[] requiredScopes = null)
{
string[] scopes = requiredScopes ?? _configuration["CalledApi:CalledApiScopes"]?.Split(' ');
string apiUrl = (_configuration["CalledApi:CalledApiUrl"] as string)?.TrimEnd('/') + $"/{relativeEndpoint}";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public IndexModel(ILogger<IndexModel> logger,

public async Task OnGet()
{
ViewData["ApiResult"] = await _downstreamWebApi.CallWebApi();
ViewData["ApiResult"] = await _downstreamWebApi.CallWebApiAsync();
}
#elseif (GenerateGraph)
private readonly GraphServiceClient _graphServiceClient;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ namespace Company.WebApplication1
{
public interface IDownstreamWebApi
{
Task<string> CallWebApi(string relativeEndpoint = "", string[] requiredScopes = null);
Task<string> CallWebApiAsync(string relativeEndpoint = "", string[] requiredScopes = null);
}

public static class DownstreamWebApiExtensions
Expand Down Expand Up @@ -46,7 +46,7 @@ public DownstreamWebApi(
/// not specified, uses scopes from the configuration</param>
/// <param name="relativeEndpoint">Endpoint relative to the CalledApiUrl configuration</param>
/// <returns>A JSON string representing the result of calling the Web API</returns>
public async Task<string> CallWebApi(string relativeEndpoint = "", string[] requiredScopes = null)
public async Task<string> CallWebApiAsync(string relativeEndpoint = "", string[] requiredScopes = null)
{
string[] scopes = requiredScopes ?? _configuration["CalledApi:CalledApiScopes"]?.Split(' ');
string apiUrl = (_configuration["CalledApi:CalledApiUrl"] as string)?.TrimEnd('/') + $"/{relativeEndpoint}";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public HomeController(ILogger<HomeController> logger,
[AuthorizeForScopes(ScopeKeySection = "CalledApi:CalledApiScopes")]
public async Task<IActionResult> Index()
{
ViewData["ApiResult"] = await _downstreamWebApi.CallWebApi();
ViewData["ApiResult"] = await _downstreamWebApi.CallWebApiAsync();
return View();
}
#elseif (GenerateGraph)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ namespace Company.WebApplication1
{
public interface IDownstreamWebApi
{
Task<string> CallWebApi(string relativeEndpoint = "", string[] requiredScopes = null);
Task<string> CallWebApiAsync(string relativeEndpoint = "", string[] requiredScopes = null);
}

public static class DownstreamWebApiExtensions
Expand Down Expand Up @@ -46,7 +46,7 @@ public DownstreamWebApi(
/// not specified, uses scopes from the configuration</param>
/// <param name="relativeEndpoint">Endpoint relative to the CalledApiUrl configuration</param>
/// <returns>A JSON string representing the result of calling the Web API</returns>
public async Task<string> CallWebApi(string relativeEndpoint = "", string[] requiredScopes = null)
public async Task<string> CallWebApiAsync(string relativeEndpoint = "", string[] requiredScopes = null)
{
string[] scopes = requiredScopes ?? _configuration["CalledApi:CalledApiScopes"]?.Split(' ');
string apiUrl = (_configuration["CalledApi:CalledApiUrl"] as string)?.TrimEnd('/') + $"/{relativeEndpoint}";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public async Task<IEnumerable<WeatherForecast>> Get()
{
HttpContext.VerifyUserHasAnyAcceptedScope(scopeRequiredByApi);

string downstreamApiResult = await _downstreamWebApi.CallWebApi();
string downstreamApiResult = await _downstreamWebApi.CallWebApiAsync();

var rng = new Random();
return Enumerable.Range(1, 5).Select(index => new WeatherForecast
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ namespace Company.WebApplication1
{
public interface IDownstreamWebApi
{
Task<string> CallWebApi(string relativeEndpoint = "", string[] requiredScopes = null);
Task<string> CallWebApiAsync(string relativeEndpoint = "", string[] requiredScopes = null);
}

public static class DownstreamWebApiExtensions
Expand Down Expand Up @@ -46,7 +46,7 @@ public DownstreamWebApi(
/// not specified, uses scopes from the configuration</param>
/// <param name="relativeEndpoint">Endpoint relative to the CalledApiUrl configuration</param>
/// <returns>A JSON string representing the result of calling the Web API</returns>
public async Task<string> CallWebApi(string relativeEndpoint = "", string[] requiredScopes = null)
public async Task<string> CallWebApiAsync(string relativeEndpoint = "", string[] requiredScopes = null)
{
string[] scopes = requiredScopes ?? _configuration["CalledApi:CalledApiScopes"]?.Split(' ');
string apiUrl = (_configuration["CalledApi:CalledApiUrl"] as string)?.TrimEnd('/') + $"/{relativeEndpoint}";
Expand Down
2 changes: 1 addition & 1 deletion tests/BlazorServerCallsGraph/Pages/CallWebApi.razor
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,6 @@ else

protected override async Task OnInitializedAsync()
{
apiResult = await downstreamAPI.CallWebApi();
apiResult = await downstreamAPI.CallWebApiAsync();
}
}
4 changes: 2 additions & 2 deletions tests/BlazorServerCallsGraph/Services/DownstreamWebApi.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ namespace blazor
{
public interface IDownstreamWebApi
{
Task<string> CallWebApi(string relativeEndpoint = "", string[] requiredScopes = null);
Task<string> CallWebApiAsync(string relativeEndpoint = "", string[] requiredScopes = null);
}

public static class DownstreamWebApiExtensions
Expand Down Expand Up @@ -49,7 +49,7 @@ public DownstreamWebApi(
/// not specified, uses scopes from the configuration</param>
/// <param name="relativeEndpoint">Endpoint relative to the CalledApiUrl configuration</param>
/// <returns>A JSON string representing the result of calling the Web API</returns>
public async Task<string> CallWebApi(string relativeEndpoint = "", string[] requiredScopes = null)
public async Task<string> CallWebApiAsync(string relativeEndpoint = "", string[] requiredScopes = null)
{
string[] scopes = requiredScopes ?? _configuration["CalledApi:CalledApiScopes"]?.Split(' ');
string apiUrl = (_configuration["CalledApi:CalledApiUrl"] as string)?.TrimEnd('/') + $"/{relativeEndpoint}";
Expand Down

0 comments on commit 32e8caa

Please sign in to comment.