ASP.NET Core 1.0?е???-?м????
???????????? ???????[ 2016/6/12 14:06:37 ] ????????ASP.NET ???????????
????ASP.NET Core 1.0?????Katana??????????(Pipeline)??????????????????MVC????鶼???м??(Middleware)????????????С??????????????????????????????????????????????????Middleware????????С???????????????“????-???”?????????——?????????????????????
??????????????????????????????“???-?м????Pipeline-Middleware)”???ɡ?
?????????????”???-?м????”??“????”????“?????”????????????
?????????????-?м??????
??????????г??????????????????????е?????????м???????????????У???????????????м?????ζ???????????????????????м???????????????????????????????
???????????????
???????????????????????????????????????-?м????????м??(Middleware)?????????
????public interface IMiddleware
????{
????Request ProcessRequest(Request request);
????Response ProcessResponse(Response response);
????}
???????(Pipeline)??????????????м??(Middleware)??
????public interface IApplicationBuilder
????{
????void Use(IMiddleware middleware);
????void UseArrange(List middlewares);
????Context Run(Context context);
????}
???????IApplicationBuilder??
public class ApplicationBuilder : IApplicationBuilder
{
public IWindsorContainer Container { get; private set; }
private readonly List _middlewares;
public ApplicationBuilder(IWindsorContainer container)
{
Contract.Requires(container!=null??"container!=null");
_middlewares=new List();
Container = container;
}
public void Use(IMiddleware middleware)
{
Contract.Requires(middleware != null?? "middleware!=null");
_middlewares.Add(middleware);
}
public void UseArrange(List middlewares)
{
Contract.Requires(middlewares != null?? "middlewares!=null");
_middlewares.AddRange(middlewares);
}
public Context Run(Context context)
{
Contract.Requires(context!=null??"context!=null");
var request=context.Request;
var response=context.Response;
foreach (var middleware in _middlewares)
{
request = middleware.ProcessRequest(request);
}
_middlewares.Reverse();
foreach (var middleware in _middlewares)
{
response = middleware.ProcessResponse(response);
}
return new Context(request??response);
}
}
??????
???·???
??????????????????
2023/3/23 14:23:39???д?ò??????????
2023/3/22 16:17:39????????????????????Щ??
2022/6/14 16:14:27??????????????????????????
2021/10/18 15:37:44???????????????
2021/9/17 15:19:29???·???????·
2021/9/14 15:42:25?????????????
2021/5/28 17:25:47??????APP??????????
2021/5/8 17:01:11