sanity checks @ startup
parent
3c6b013d72
commit
59e478fc41
@ -0,0 +1,47 @@
|
||||
using System;
|
||||
using Google.Apis.Auth.OAuth2;
|
||||
using Microsoft.AspNet.Builder;
|
||||
using Microsoft.AspNet.Hosting;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
|
||||
namespace Yavsc
|
||||
{
|
||||
public partial class Startup
|
||||
{
|
||||
public void CheckServices(IServiceCollection services)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public void CheckApp(IApplicationBuilder app,
|
||||
SiteSettings siteSettings, IHostingEnvironment env,
|
||||
ILoggerFactory loggerFactory
|
||||
)
|
||||
{
|
||||
var logger = loggerFactory.CreateLogger<Startup>();
|
||||
|
||||
var creds = GoogleSettings?.Account?.private_key;
|
||||
if (creds==null)
|
||||
throw new InvalidOperationException("No Google API credential");
|
||||
var initializer = new ServiceAccountCredential.Initializer(Startup.GoogleSettings.Account.client_email);
|
||||
initializer = initializer.FromPrivateKey(Startup.GoogleSettings.Account.private_key);
|
||||
if (initializer==null)
|
||||
|
||||
throw new InvalidOperationException("Invalid Google API credential");
|
||||
|
||||
foreach (var feature in app.ServerFeatures)
|
||||
{
|
||||
var val = JsonConvert.SerializeObject(feature.Value);
|
||||
logger.LogInformation( $"#Feature _{feature.Key}_: {val}" );
|
||||
}
|
||||
foreach (var prop in app.Properties)
|
||||
{
|
||||
var val = JsonConvert.SerializeObject(prop.Value);
|
||||
logger.LogInformation( $"#Property _{prop.Key}_: {val}" );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue