In ASP.NET Core, middleware are C# classes that can handle an HTTP request or response.
Middleware can either:
More about it here.
This is example of very simple middleware.
You have to register it, using IGrandStartup interface. To do it, you have to create another file.
That's it! You have your own working middleware.