Runtime context for ASP.NET Core request.
상속: Pchp.Core.Context
예제 #1
0
 /// <summary>
 /// Installs PHP request handler within the application.
 /// </summary>
 public static IApplicationBuilder UsePhp(this IApplicationBuilder builder /* , TODO: options, allowed extensions, directory */)
 {
     return builder.Use(new Func<RequestDelegate, RequestDelegate>(next => async context =>
     {
         var script = RequestContextCore.ResolveScript(context.Request);
         if (script.IsValid)
         {
             await Task.Run(() =>
             {
                 using (var phpctx = new RequestContextCore(context))
                 {
                     script.MainMethod(phpctx, phpctx.Globals, null);
                 }
             });
         }
         else
         {
             await next(context);
         }
     }));
 }
예제 #2
0
 /// <summary>
 /// Handles new context.
 /// </summary>
 void OnContextCreated(RequestContextCore ctx)
 {
     _options.BeforeRequest?.Invoke(ctx);
 }