csharp-netcore-functions.functions.mustache Maven / Gradle / Ivy
{{>partial_header}}
using System;
using System.Net;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Azure.WebJobs;
using Microsoft.Azure.WebJobs.Extensions.Http;
namespace {{packageName}}.{{apiPackage}}
{ {{#operations}}
public partial {{#classModifier}}{{classModifier}} {{/classModifier}}class {{classname}}
{ {{#operation}}
[FunctionName("{{classname}}_{{operationId}}")]
public async Task _{{operationId}}([HttpTrigger(AuthorizationLevel.Anonymous, "{{httpMethod}}", Route = "{{{apiBasePath}}}{{{path}}}")]HttpRequest req, ExecutionContext context{{#allParams}}{{#isPathParam}}, {{>pathParam}}{{/isPathParam}}{{/allParams}})
{
var method = this.GetType().GetMethod("{{operationId}}");
return method != null
? (await ((Task)method.Invoke(this, new object[] { req, context{{#allParams}}{{#isPathParam}}, {{/isPathParam}}{{/allParams}} })).ConfigureAwait(false))
: new StatusCodeResult((int)HttpStatusCode.NotImplemented);
}
{{/operation}}
}
}
{{/operations}}