[C# Library] Create a Function abstract class similar to Microsoft.AspNetCore.Mvc.Controller
- Dominant language
- PowerShell
- Stars
- 1.1k
- Forks
- 215
- Avg merge
- 4h 2m
- Merged PRs (30d)
- 1
Description
A while ago support for Dependency Injection was introduced, this moves us away from using static classes and static methods and brings us closer to how we model APIs using ASP.NET Core.
There are community requests to improve the Model Binding support (allow access to the HttpRequest object while also leveraging Model Binding) and in general, I think that modeling the Azure Functions experience to be as close as possible to an ASP.NET Core Api Controller would make adoption even easier for those trying to migrate to a microservice serverless cloud-native architecture.
One opt-in feature that could be easy to implement is the creation of a (Http)Function abstract class. Such class could contains the same helper methods a Microsoft.AspNetCore.Mvc.Controller contains specially tailored to implement Http triggered functions.
The most important one could be to hold the HttpContext property, given access to every function to the Request, Reponse, User, and several other useful objects.
This is a snapshot of how a microservice with several related operations (functions) might look like with this approach:

Bonus: We could add some defaults like marking every public method an http triggered function, removing the need to annotate the first parameter with HttpTrigger, and leveraging the same [Route], [HttpGet], [ProduceResponseType], etc.
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.