base on Request/response Inspector middleware for ASP.NET Core # <img src="docs/images/logo.svg" alt="" width="32" /> Rin **R**equest/response **In**spector middleware for ASP.NET Core. like Glimpse. [![Build-Release](https://github.com/mayuki/Rin/workflows/Build-Release/badge.svg)](https://github.com/mayuki/Rin/actions?query=workflow%3ABuild-Release) [![Build-Development](https://github.com/mayuki/Rin/workflows/Build-Development/badge.svg)](https://github.com/mayuki/Rin/actions?query=workflow%3ABuild-Development) [![NuGet version](https://badge.fury.io/nu/Rin.svg)](https://badge.fury.io/nu/Rin) Rin captures HTTP requests to ASP.NET Core app and provides viewer for captured data. It's useful tool to debug your Web application (e.g. Web sites, API apps). ![](docs/images/Demo-01.gif) # ✅ Features ## Capture requests and responses Rin captures HTTP traffics between the ASP.NET Core app and any clients. - Headers + Body - Traces (`Microsoft.Extensions.Logging.ILogger`, log4net, ...) - Unhandled Exception ## Inspect from Web browser in realtime ### View events timeline Rin inspector displays events that occurred while processing a request. ![](docs/images/Screenshot-02.png) ### Preview a request/response body Rin inspector can display request and response body with a preview. (e.g. JSON, Image, HTML, JavaScript ...) ![](docs/images/Screenshot-03.png) ### View related trace logs Rin captures a request and response. Also, it captures logs while processing a request. - Built-in `Microsoft.Extensions.Logging.ILogger` integration - log4net Appender ### Save and export request/response You can replay a request easily using cURL and LINQPad. - Save request/response body - Copy request as cURL and C# ### Integrate with ASP.NET Core MVC - Record timings of view rendering and action execution - In-View Inspector (like MiniProfiler) ![](docs/images/Screenshot-04.png) # 📝 Requirements - .NET Core 3.1+ - ASP.NET Core 3.1+ - Modern browser (e.g. Microsoft Edge, Google Chrome, Firefox, Safari...) - WebSocket connectivity # ⚡ QuickStart ## Install NuGet Package ### Using Visual Studio `Dependencies` -> `Manage NuGet Packages...` -> Search and install `Rin` and `Rin.Mvc` (if your project is built with ASP.NET Core MVC) package. ### Using dotnet command ``` dotnet add package Rin dotnet add package Rin.Mvc ``` ### Using Package Manager ``` Install-Package Rin Install-Package Rin.Mvc ``` ## Setup and configure Rin ### Program.cs ```csharp public static IWebHostBuilder CreateWebHostBuilder(string[] args) => WebHost.CreateDefaultBuilder(args) .ConfigureLogging(configure => { // Add: Enable Rin Logger configure.AddRinLogger(); }) .UseStartup<Startup>(); ``` ### Startup.cs ```csharp public class Startup { ... public void ConfigureServices(IServiceCollection services) { ... services.AddControllersWithViews() // Add(option): Enable ASP.NET Core MVC support if the project built with ASP.NET Core MVC .AddRinMvcSupport(); // Add: Register Rin services services.AddRin(); } ... public void Configure(IApplicationBuilder app, IHostingEnvironment env) { if (env.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(); } ... } } ``` ### _Layout.cshtml (for ASP.NET Core MVC) ```cshtml @inject Rin.Mvc.View.RinHelperService RinHelper ... <environment include="Development"> <link rel="stylesheet" href="~/lib/bootstrap/dist/css/bootstrap.css" /> <link rel="stylesheet" href="~/css/site.css" /> @* Add: Enable In-View Inspector for ASP.NET Core MVC *@ @RinHelper.RenderInViewInspector() </environment> ... ``` ## Start the application and open Inspector on the web Launch the app, then open `http://[Host:Port]/rin/` in the browser, you can see Rin Inspector now. # 🔨 Develop and build Rin Inspector (client side) Rin Inspector (client side) codes is separated from Rin core C# project. If you want to develop Rin (C#) or launch a sample project, you need to build and deploy the artifacts. ## [Rin.Frontend, Rin.Mvc.Frontend] Setup and start the development server - `yarn` - `yarn start` ## [Rin.Frontend] Build Rin/Resources.zip - `yarn build` - `yarn pack` ## [Rin.Mvc.Frontend] Build Rin.Mvc/EmbeddedResources - `yarn build` - `copy .\dist\static\main.js* ..\Rin.Mvc\EmbeddedResources\` # License [MIT License](LICENSE) ", Assign "at most 3 tags" to the expected json: {"id":"7388","tags":[]} "only from the tags list I provide: [{"id":77,"name":"3d"},{"id":89,"name":"agent"},{"id":17,"name":"ai"},{"id":54,"name":"algorithm"},{"id":24,"name":"api"},{"id":44,"name":"authentication"},{"id":3,"name":"aws"},{"id":27,"name":"backend"},{"id":60,"name":"benchmark"},{"id":72,"name":"best-practices"},{"id":39,"name":"bitcoin"},{"id":37,"name":"blockchain"},{"id":1,"name":"blog"},{"id":45,"name":"bundler"},{"id":58,"name":"cache"},{"id":21,"name":"chat"},{"id":49,"name":"cicd"},{"id":4,"name":"cli"},{"id":64,"name":"cloud-native"},{"id":48,"name":"cms"},{"id":61,"name":"compiler"},{"id":68,"name":"containerization"},{"id":92,"name":"crm"},{"id":34,"name":"data"},{"id":47,"name":"database"},{"id":8,"name":"declarative-gui "},{"id":9,"name":"deploy-tool"},{"id":53,"name":"desktop-app"},{"id":6,"name":"dev-exp-lib"},{"id":59,"name":"dev-tool"},{"id":13,"name":"ecommerce"},{"id":26,"name":"editor"},{"id":66,"name":"emulator"},{"id":62,"name":"filesystem"},{"id":80,"name":"finance"},{"id":15,"name":"firmware"},{"id":73,"name":"for-fun"},{"id":2,"name":"framework"},{"id":11,"name":"frontend"},{"id":22,"name":"game"},{"id":81,"name":"game-engine "},{"id":23,"name":"graphql"},{"id":84,"name":"gui"},{"id":91,"name":"http"},{"id":5,"name":"http-client"},{"id":51,"name":"iac"},{"id":30,"name":"ide"},{"id":78,"name":"iot"},{"id":40,"name":"json"},{"id":83,"name":"julian"},{"id":38,"name":"k8s"},{"id":31,"name":"language"},{"id":10,"name":"learning-resource"},{"id":33,"name":"lib"},{"id":41,"name":"linter"},{"id":28,"name":"lms"},{"id":16,"name":"logging"},{"id":76,"name":"low-code"},{"id":90,"name":"message-queue"},{"id":42,"name":"mobile-app"},{"id":18,"name":"monitoring"},{"id":36,"name":"networking"},{"id":7,"name":"node-version"},{"id":55,"name":"nosql"},{"id":57,"name":"observability"},{"id":46,"name":"orm"},{"id":52,"name":"os"},{"id":14,"name":"parser"},{"id":74,"name":"react"},{"id":82,"name":"real-time"},{"id":56,"name":"robot"},{"id":65,"name":"runtime"},{"id":32,"name":"sdk"},{"id":71,"name":"search"},{"id":63,"name":"secrets"},{"id":25,"name":"security"},{"id":85,"name":"server"},{"id":86,"name":"serverless"},{"id":70,"name":"storage"},{"id":75,"name":"system-design"},{"id":79,"name":"terminal"},{"id":29,"name":"testing"},{"id":12,"name":"ui"},{"id":50,"name":"ux"},{"id":88,"name":"video"},{"id":20,"name":"web-app"},{"id":35,"name":"web-server"},{"id":43,"name":"webassembly"},{"id":69,"name":"workflow"},{"id":87,"name":"yaml"}]" returns me the "expected json"