diff --git a/Izzy.Web/Client/public/manifest.json b/Izzy.Web/Client/public/manifest.json
index 1f2f141..84f25e5 100755
--- a/Izzy.Web/Client/public/manifest.json
+++ b/Izzy.Web/Client/public/manifest.json
@@ -1,6 +1,6 @@
{
- "short_name": "React App",
- "name": "Create React App Sample",
+ "short_name": "Izzy",
+ "name": "Izzy - рассчитай, сколько тебе должны после вечеринки",
"icons": [
{
"src": "favicon.ico",
@@ -10,6 +10,6 @@
],
"start_url": ".",
"display": "standalone",
- "theme_color": "#000000",
+ "theme_color": "#8fd5eb",
"background_color": "#ffffff"
}
diff --git a/Izzy.Web/Client/src/YandexMetrica.tsx b/Izzy.Web/Client/src/YandexMetrica.tsx
index 6936c9a..c26914c 100644
--- a/Izzy.Web/Client/src/YandexMetrica.tsx
+++ b/Izzy.Web/Client/src/YandexMetrica.tsx
@@ -14,8 +14,15 @@ export const YandexMetrica = (props: YandexMetricaProps) => {
if (isProd()) {
return (
)
} else {
diff --git a/Izzy.Web/Controllers/CalculatorController.cs b/Izzy.Web/Controllers/CalculatorController.cs
index 5e08d06..84efd0b 100644
--- a/Izzy.Web/Controllers/CalculatorController.cs
+++ b/Izzy.Web/Controllers/CalculatorController.cs
@@ -3,6 +3,7 @@
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Logging;
using Izzy.Web.Model;
+using Newtonsoft.Json;
namespace Izzy.Web.Controllers
{
@@ -20,16 +21,17 @@ public CalculatorController(ILogger logger)
public IActionResult Calculate([FromBody] IEnumerable persons)
{
if (ModelState.IsValid) {
+ this._logger.LogInformation("Persons was: {persons}", persons);
return new OkObjectResult(
new Receipt(persons)
.Transfers()
);
} else {
+ this._logger.LogInformation("Invalid request: {persons}", persons);
return new BadRequestObjectResult(
"Name should have string type, Roubles should have number type"
);
}
-
}
}
}
diff --git a/Izzy.Web/Izzy.Web.csproj b/Izzy.Web/Izzy.Web.csproj
index 38195ff..51ba245 100644
--- a/Izzy.Web/Izzy.Web.csproj
+++ b/Izzy.Web/Izzy.Web.csproj
@@ -12,6 +12,12 @@
+
+
+
+
+
+
diff --git a/Izzy.Web/Middlewares/HealthCheckMiddleware.cs b/Izzy.Web/Middlewares/HealthCheckMiddleware.cs
new file mode 100644
index 0000000..6b9aaf3
--- /dev/null
+++ b/Izzy.Web/Middlewares/HealthCheckMiddleware.cs
@@ -0,0 +1,33 @@
+using System;
+using System.Threading.Tasks;
+using Microsoft.AspNetCore.Http;
+using Microsoft.Net.Http.Headers;
+
+namespace Izzy.Web.Middlewares
+{
+ public class HealthCheckMiddleware
+ {
+ private const string _path = "/healthcheck";
+ private readonly RequestDelegate _next;
+
+ public HealthCheckMiddleware(RequestDelegate next)
+ {
+ _next = next;
+ }
+
+ public async Task Invoke(HttpContext context)
+ {
+ if (!context.Request.Path.Equals(_path, StringComparison.OrdinalIgnoreCase))
+ {
+ await _next(context);
+ }
+ else
+ {
+ context.Response.ContentType = "text/plain";
+ context.Response.StatusCode = 200;
+ context.Response.Headers.Add(HeaderNames.Connection, "close");
+ await context.Response.WriteAsync("OK");
+ }
+ }
+ }
+}
diff --git a/Izzy.Web/Model/Person.cs b/Izzy.Web/Model/Person.cs
index 0569d72..3ce2826 100644
--- a/Izzy.Web/Model/Person.cs
+++ b/Izzy.Web/Model/Person.cs
@@ -16,5 +16,10 @@ public Person(String name, Decimal roubles)
this.Name = name;
this.Roubles = roubles;
}
+
+ public override string ToString()
+ {
+ return JsonConvert.SerializeObject(this);
+ }
}
}
diff --git a/Izzy.Web/Program.cs b/Izzy.Web/Program.cs
index f4631ec..cb1b767 100644
--- a/Izzy.Web/Program.cs
+++ b/Izzy.Web/Program.cs
@@ -1,5 +1,13 @@
+using System;
+using System.IO;
+using System.Net;
using Microsoft.AspNetCore;
using Microsoft.AspNetCore.Hosting;
+using Microsoft.Extensions.Configuration;
+using Sentry;
+using Serilog;
+using Serilog.Events;
+using Serilog.Formatting.Compact;
namespace Izzy.Web
{
@@ -13,6 +21,32 @@ public static void Main(string[] args)
private static IWebHostBuilder CreateWebHostBuilder(string[] args) =>
WebHost.CreateDefaultBuilder(args)
.UseStartup()
- .UseUrls("http://0.0.0.0:5000");
+ .UseUrls("http://0.0.0.0:5000")
+ .UseSerilog((h, c) =>
+ c.Enrich.FromLogContext()
+ .MinimumLevel.Warning()
+ .MinimumLevel.Override("Izzy.Web", LogEventLevel.Information)
+ .WriteTo.ColoredConsole()
+ .WriteTo.Sentry(s =>
+ {
+ s.MinimumBreadcrumbLevel = LogEventLevel.Debug;
+ s.MinimumEventLevel = LogEventLevel.Error;
+
+ })
+ )
+ .UseSentry(options =>
+ {
+ options.Release = "1.0.5";
+ options.Environment = CurrentEnv();
+ options.MaxQueueItems = 100;
+ options.ShutdownTimeout = TimeSpan.FromSeconds(5);
+ options.DecompressionMethods = DecompressionMethods.None;
+ })
+ ;
+
+ private static String CurrentEnv()
+ {
+ return Environment.GetEnvironmentVariable("ASPNETCORE_ENVIRONMENT") ?? "Production";
+ }
}
}
diff --git a/Izzy.Web/Startup.cs b/Izzy.Web/Startup.cs
index 74834ac..566d9f9 100644
--- a/Izzy.Web/Startup.cs
+++ b/Izzy.Web/Startup.cs
@@ -4,6 +4,7 @@
using Microsoft.AspNetCore.SpaServices.ReactDevelopmentServer;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
+using Izzy.Web.Middlewares;
namespace Izzy.Web
{
@@ -40,6 +41,7 @@ public void Configure(IApplicationBuilder app, IHostingEnvironment env)
app.UseHsts();
}
+ app.UseMiddleware();
app.UseStaticFiles();
app.UseSpaStaticFiles();
diff --git a/Izzy.Web/appsettings.Development.json b/Izzy.Web/appsettings.Development.json
index a2880cb..630ecd1 100644
--- a/Izzy.Web/appsettings.Development.json
+++ b/Izzy.Web/appsettings.Development.json
@@ -1,7 +1,7 @@
{
"Logging": {
"LogLevel": {
- "Default": "Debug",
+ "Default": "Information",
"System": "Information",
"Microsoft": "Information"
}
diff --git a/Izzy.Web/appsettings.json b/Izzy.Web/appsettings.json
index 7376aad..9f6ffe8 100644
--- a/Izzy.Web/appsettings.json
+++ b/Izzy.Web/appsettings.json
@@ -4,5 +4,9 @@
"Default": "Warning"
}
},
- "AllowedHosts": "*"
+ "AllowedHosts": "*",
+ "Sentry": {
+ "Dsn": "https://49b7a46a2fc040189c50bf2948bd4732@sentry.io/1385588",
+ "IncludeRequestPayload": true
+ }
}