diff --git a/Yavsc/Startup/Startup.SanityChecks.cs b/Yavsc/Startup/Startup.SanityChecks.cs new file mode 100644 index 00000000..c49347ad --- /dev/null +++ b/Yavsc/Startup/Startup.SanityChecks.cs @@ -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(); + + 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}" ); + } + } + } +} diff --git a/Yavsc/Yavsc.csproj b/Yavsc/Yavsc.csproj index 59602a41..0e42c784 100644 --- a/Yavsc/Yavsc.csproj +++ b/Yavsc/Yavsc.csproj @@ -1226,6 +1226,10 @@ + + + +