Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
OWIN Middleware
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using Owin;
namespace Middlewares
{
using AppFunc = Func<IDictionary<string, object>, Task>;
public class Startup
{
public void Configuration(IAppBuilder app)
{
var middleware = new Middleware();
app.Use(middleware, 10, "auth");
}
}
internal class Middleware
{
private AppFunc _next;
private int _number;
private string _name;
public void Initialize(AppFunc next, int number, string name)
{
_next = next;
_number = number;
_name = name;
}
public async Task Invoke(IDictionary<string, object> env)
{
Console.WriteLine("before. number: {0}, name: {1}", _number, _name);
await _next.Invoke(env);
Console.WriteLine("after. number: {0}, name: {1}", _number, _name);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.