All Downloads are FREE. Search and download functionalities are using the official Maven repository.

csharp-functions.function.mustache.bak Maven / Gradle / Ivy

There is a newer version: 7.6.0
Show newest version
using System.IO;
using System.Net;
using System.Threading.Tasks;
using System.ComponentModel.DataAnnotations;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Azure.WebJobs;
using Microsoft.Azure.WebJobs.Extensions.Http;
using Microsoft.Azure.WebJobs.Extensions.OpenApi.Core.Attributes;
using Microsoft.Azure.WebJobs.Extensions.OpenApi.Core.Enums;
using Microsoft.Extensions.Logging;
using Microsoft.OpenApi.Models;
using Newtonsoft.Json;

namespace {{apiPackage}}
{ {{#operations}}
    public partial {{#classModifier}}{{classModifier}} {{/classModifier}}class {{classname}}
    { {{#operation}}
        [FunctionName("{{classname}}_{{operationId}}")]
        public async Task _{{operationId}}([HttpTrigger(AuthorizationLevel.Anonymous, "{{httpMethod}}", Route = "{{{path}}}")]HttpRequest req, ExecutionContext context{{#allParams}}{{#isPathParam}}, {{>pathParam}}{{/isPathParam}}{{/allParams}}){{^generateBody}};{{/generateBody}}
        {{#generateBody}}
        {
            var method = this.GetType().GetMethod("{{operationId}}");

            return method != null 
                ? (await ((Task)method.Invoke(this, new object[] { req, context{{#allParams}}{{#isPathParam}}, {{>paramName}}{{/isPathParam}}{{/allParams}} })).ConfigureAwait(false))
                : new StatusCodeResult((int)HttpStatusCode.NotImplemented);
        }
        {{/generateBody}}
        {{/operation}}
    }
{{/operations}}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy