Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add async to CallWebApiAsync #358

Merged
merged 1 commit into from
Jul 23, 2020
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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