Skip to content

Instantly share code, notes, and snippets.

@StefH
Last active September 10, 2019 17:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save StefH/08488c42bdee9c5cc86aa5f8f8209b95 to your computer and use it in GitHub Desktop.
Save StefH/08488c42bdee9c5cc86aa5f8f8209b95 to your computer and use it in GitHub Desktop.
AzureFunction QueryFunction
[FunctionName("QuerySmartContractFunction")]
public static async Task<IActionResult> RunQueryFunctionAsync(
[HttpTrigger(AuthorizationLevel.Function, "post")]HttpRequest req,
[Inject] ISmartContractService service,
ILogger logger)
{
_logger.LogInformation("QuerySmartContractFunction");
string body = await req.ReadAsStringAsync();
var request = JsonConvert.DeserializeObject<SmartContractFunctionRequest>(body);
try
{
var result = await _service.QueryFunctionAsync(request);
return new JsonResult(result, JsonSerializerSettings);
}
catch (Exception exception)
{
_logger.LogError(exception, "QuerySmartContractFunction failed");
return new JsonResult(new { exception.Message }, JsonSerializerSettings);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment