public async Task <ActionResult <IEnumerable <GameServerInfo> > > Get([FromQuery] int limit = 100) { ResponseWrapper serverList = null; try { logger.LogInformation("Acquiring server list with {SearchLimit} results.", limit); // Approach using LogMessage.Define logger.GameServerListRequested(limit); serverList = await steamClient.GetServerList(steamOptions.Value.DeveloperApiKey, limit, steamOptions.Value.DefaultResponseFormat); // Processing and filtering of results // and other business logic } catch (HttpRequestException ex) { logger.LogWarning(ex, "Http request failed."); return(StatusCode(StatusCodes.Status502BadGateway, "Failed request to external resource.")); } catch (TimeoutRejectedException ex) { logger.LogWarning(ex, "Timeout occurred when retrieving server list for {SearchLimit} items.", limit); return(StatusCode(StatusCodes.Status504GatewayTimeout, "Timeout on external web request.")); } catch (Exception ex) { logger.LogError(ex, "Unknown exception occurred while retrieving server list"); // Exception shielding for all other exceptions return(StatusCode(StatusCodes.Status500InternalServerError, "Request could not be processed.")); } return(Ok(serverList.Response.Servers)); }
public async Task <ActionResult <string> > Get([FromQuery] int limit = 100) { ISteamClient proxy = RestService.For <ISteamClient>(Configuration["SteamApiOptions:BaseUrl"]); return(await proxy.GetServerList(Configuration["SteamApiOptions:DeveloperApiKey"], limit)); }