Skip to content

Commit

Permalink
集成了Rin监控
Browse files Browse the repository at this point in the history
  • Loading branch information
Deali-Axy committed Feb 6, 2024
1 parent ea5d3da commit f82aeea
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 2 deletions.
25 changes: 25 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
**/.dockerignore
**/.env
**/.git
**/.gitignore
**/.project
**/.settings
**/.toolstarget
**/.vs
**/.vscode
**/.idea
**/*.*proj.user
**/*.dbmdl
**/*.jfm
**/azds.yaml
**/bin
**/charts
**/docker-compose*
**/Dockerfile*
**/node_modules
**/npm-debug.log
**/obj
**/secrets.dev.yaml
**/values.dev.yaml
LICENSE
README.md
18 changes: 16 additions & 2 deletions StarBlog.Web/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,16 @@

var builder = WebApplication.CreateBuilder(args);

// Enable Rin Logger
builder.Logging.AddRinLogger();

var mvcBuilder = builder.Services.AddControllersWithViews(
options => { options.Filters.Add<ResponseWrapperFilter>(); }
);
).AddRinMvcSupport();

// Register Rin services
builder.Services.AddRin();

// 开发模式启用Razor页面动态编译
if (builder.Environment.IsDevelopment()) {
mvcBuilder.AddRazorRuntimeCompilation();
Expand Down Expand Up @@ -74,8 +81,15 @@
var app = builder.Build();

// Configure the HTTP request pipeline.
if (!app.Environment.IsDevelopment()) {
if (app.Environment.IsDevelopment()) {
// Add: Enable request/response recording and serve a inspector frontend.
// Important: `UseRin` (Middlewares) must be top of the HTTP pipeline.
app.UseRin();
// Add(option): Enable ASP.NET Core MVC support if the project built with ASP.NET Core MVC
app.UseRinMvcSupport();
app.UseDeveloperExceptionPage();
// Add: Enable Exception recorder. this handler must be after `UseDeveloperExceptionPage`.
app.UseRinDiagnosticsHandler();
// The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts.
app.UseHsts();
}
Expand Down
2 changes: 2 additions & 0 deletions StarBlog.Web/StarBlog.Web.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@
<PackageReference Include="Microsoft.CodeAnalysis.Common" Version="4.0.0" />
<PackageReference Include="Microsoft.CodeAnalysis.CSharp" Version="4.0.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="6.0.18" />
<PackageReference Include="Rin" Version="2.6.0" />
<PackageReference Include="Rin.Mvc" Version="2.6.0" />
<PackageReference Include="RobotsTxtCore" Version="2.1.1" />
<PackageReference Include="SixLabors.ImageSharp" Version="2.1.3" />
<PackageReference Include="SixLabors.ImageSharp.Web" Version="2.0.2" />
Expand Down
5 changes: 5 additions & 0 deletions StarBlog.Web/Views/Shared/_Layout.cshtml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
@using StarBlog.Web.Utils
@inject StarBlog.Web.Contrib.SiteMessage.MessageService Messages
@inject Rin.Mvc.View.RinHelperService RinHelper

<!DOCTYPE html>
<html lang="en">
Expand All @@ -22,6 +23,10 @@
<link rel="stylesheet" href="~/css/metro.css">
<link rel="stylesheet" href="~/css/footer.css">
<script src="~/js/site.preload.js"></script>
<environment include="Development">
@* Add: Enable In-View Inspector for ASP.NET Core MVC *@
@RinHelper.RenderInViewInspector()
</environment>

@await RenderSectionAsync("head", false)
</head>
Expand Down

0 comments on commit f82aeea

Please sign in to comment.