public static async Task <HttpResponseMessage> Run([HttpTrigger(AuthorizationLevel.Anonymous, "post", Route = "tarefas/criar")] HttpRequestMessage req, TraceWriter log) { try { Task <HttpResponseMessage> result; switch (req.Method.Method) { case "POST": result = ExecutarPostAsync(req, log); break; default: result = Comum.GetBadRequest(req, log); break; } return(await result); } catch (System.Exception ex) { log.Error("Ocorreu um erro.", ex); throw; } }
public static Task <HttpResponseMessage> Run([HttpTrigger(AuthorizationLevel.Anonymous, "get", "put", "delete", Route = "tarefas/{idTarefa?}")] HttpRequestMessage req, TraceWriter log, string idTarefa) { try { log.Info("Executando requisição."); Task <HttpResponseMessage> result; var tarefasCollections = TarefaCollection.Instance; switch (req.Method.Method) { case "GET": result = ExecutarGetAsync(req, idTarefa, log, tarefasCollections); break; case "PUT": result = ExecutarPutAsync(req, idTarefa, log, tarefasCollections); break; case "DELETE": result = ExecutarDeleteAsync(req, idTarefa, log, tarefasCollections); break; default: result = Comum.GetBadRequest(req, log); break; } log.Info("Término requisição."); return(result); } catch (System.Exception ex) { log.Error("Ocorreu um erro.", ex); throw; } }