Added environment manager and updated UI
This commit is contained in:
@@ -166,6 +166,29 @@ namespace EonaCat.DoxaApi.Middleware
|
||||
});
|
||||
}
|
||||
|
||||
// Add analytics endpoint if metrics collector is registered
|
||||
if (metricsCollector != null)
|
||||
{
|
||||
app.Map($"{prefix}/analytics", analyticsApp =>
|
||||
{
|
||||
analyticsApp.Run(async context =>
|
||||
{
|
||||
if (!HttpMethods.IsGet(context.Request.Method))
|
||||
{
|
||||
context.Response.StatusCode = 405;
|
||||
context.Response.Headers["Allow"] = "GET";
|
||||
await context.Response.WriteAsync("Method Not Allowed - use GET");
|
||||
return;
|
||||
}
|
||||
|
||||
var dashboard = metricsCollector.GetDashboard();
|
||||
context.Response.ContentType = "application/json; charset=utf-8";
|
||||
var json = JsonHelper.ToJson(dashboard, _writeOptions);
|
||||
await context.Response.WriteAsync(json, Encoding.UTF8);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
app.Map(prefix, uiApp =>
|
||||
{
|
||||
uiApp.Run(async context =>
|
||||
@@ -203,29 +226,6 @@ namespace EonaCat.DoxaApi.Middleware
|
||||
});
|
||||
});
|
||||
|
||||
// Add analytics endpoint if metrics collector is registered
|
||||
if (metricsCollector != null)
|
||||
{
|
||||
app.Map(prefix + "/analytics", analyticsApp =>
|
||||
{
|
||||
analyticsApp.Run(async context =>
|
||||
{
|
||||
if (!HttpMethods.IsGet(context.Request.Method))
|
||||
{
|
||||
context.Response.StatusCode = 405;
|
||||
context.Response.Headers["Allow"] = "GET";
|
||||
await context.Response.WriteAsync("Method Not Allowed - use GET");
|
||||
return;
|
||||
}
|
||||
|
||||
var dashboard = metricsCollector.GetDashboard();
|
||||
context.Response.ContentType = "application/json; charset=utf-8";
|
||||
var json = JsonHelper.ToJson(dashboard, _writeOptions);
|
||||
await context.Response.WriteAsync(json, Encoding.UTF8);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
return app;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user