in src/Google.Cloud.Functions.Hosting/HostingInternals.cs [61:93]
internal static IApplicationBuilder ConfigureApplication(WebHostBuilderContext context, IApplicationBuilder app, bool validateStartups)
{
if (validateStartups)
{
ValidateStartupClasses(app);
}
var configurers = app.ApplicationServices.GetServices<FunctionsStartup>();
foreach (var configurer in configurers)
{
configurer.Configure(context, app);
}
app.Map("/robots.txt", ReturnNotFound);
app.Map("/favicon.ico", ReturnNotFound);
app.Run(Execute);
// Slight hack using dependency injection to propagate the original function from ConfigureFunctionsFrameworkTarget
// to here.
var functionType = app.ApplicationServices.GetRequiredService<FunctionTypeProvider>().FunctionType;
// Note: we can't use ILogger<EntryPoint> as EntryPoint is static. This is an equivalent.
app.ApplicationServices
.GetRequiredService<ILoggerFactory>()
.CreateLogger(typeof(EntryPoint).FullName ?? "UnknownType")
.LogInformation($"Serving function {functionType.FullName}");
return app;
static void ReturnNotFound(IApplicationBuilder app) =>
app.Run(context =>
{
context.Response.StatusCode = (int) HttpStatusCode.NotFound;
return Task.CompletedTask;
});
}