Customizing ASP.NET Core 5.0 by Jürgen Gutsch
Author:Jürgen Gutsch
Language: eng
Format: epub
Publisher: Packt Publishing Pvt. Ltd.
Published: 2021-01-28T00:00:00+00:00
Rewriting a terminating middleware to current standards
If you have an existing middleware that provides a different endpoint, you should change it to use the new endpoint routing:
As an example, let's create a small dummy middleware that writes an application status to a specific route. In this demo, there is no custom route handling:public class AppStatusMiddleware
{
private readonly RequestDelegate _next;
private readonly string _status;
public AppStatusMiddleware(
RequestDelegate next, string status)
{
_next = next;
_status = status;
}
public async Task Invoke(HttpContext context)
{
await context.Response.WriteAsync(
$"Hello {_status}!");
}
}
The first thing we need to do is to write an extension method on the IEndpointRouteBuilder type. This method has a route pattern as an optional argument and returns an IEndpointConventionBuilder type to enable CORS, authentication, or other conditions to the route.
Download
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.
2021 Beginners Guide to Python Programming Language: A Crash Course to Mastering Python in One Hour by Elmer Gary & Elmer Gary(1832)
API Testing and Development with Postman by Dave Westerveld(1684)
Learning C# by Developing Games with Unity 2020 by Harrison Ferrone(1568)
Machine Learning for Algorithmic Trading by Stefan Jansen(1495)
Software Architecture for Busy Developers by Stéphane Eyskens(1487)
Hands-On ROS for Robotics Programming by Bernardo Ronquillo Japón(1460)
Delphi GUI Programming with FireMonkey by Andrea Magni(1326)
Cloud Native with Kubernetes by Alexander Raul(1292)
Game Development Projects with Unreal Engine by Hammad Fozi & Goncalo Marques & David Pereira & Devin Sherry(1278)
Automate It with Zapier by Kelly Goss(1245)
Software Architecture Patterns for Serverless Systems by John Gilbert(1237)
Practical System Programming for Rust Developers by Prabhu Eshwarla(1218)
Datadog Cloud Monitoring Quick Start Guide by Thomas Kurian Theakanath(1215)
Practical Node-RED Programming by Taiji Hagino(1201)
Mastering React Test-Driven Development by Daniel Irvine(1190)
Delphi Programming Projects by William Duarte(1180)
Learn Spring for Android Application Development by S. M. Mohi Us Sunnat(1147)
Developing Multi-Platform Apps with Visual Studio Code by Ovais Mehboob Ahmed Khan & Khusro Habib & Chris Dias(1146)
Ghidra Software Reverse Engineering for Beginners by A. P. David(1146)