Files
Disco/Disco.Services/Web/Bundles/BundleHandler.cs
T
Gary Sharp 4cd57f4a90 Update: SignalR 2.0.3 Migration; Noticeboards
Migrate all SignalR 1.x Persistent Connections to SignalR 2.x Hubs.
Abstracts ScheduledTaskStatus with core interface and adds a Mock for
optional status reporting. Noticeboards rewritten (with new theme) to be
more resilient and accurate.
2014-06-01 23:27:07 +10:00

53 lines
1.5 KiB
C#

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Web;
namespace Disco.Services.Web.Bundles
{
internal sealed class BundleHandler : IHttpHandler
{
public IBundle RequestBundle { get; private set; }
public string BundleVirtualPath { get; private set; }
public BundleHandler(IBundle requestBundle, string bundleVirtualPath)
{
this.RequestBundle = requestBundle;
this.BundleVirtualPath = bundleVirtualPath;
}
public bool IsReusable
{
get { return false; }
}
public void ProcessRequest(HttpContext context)
{
context.Response.Clear();
if (!string.IsNullOrEmpty(context.Request.Headers["If-Modified-Since"]))
context.Response.StatusCode = 304;
else
this.RequestBundle.ProcessRequest(context);
}
internal static bool RemapHandlerForBundleRequests(HttpApplication app)
{
var context = app.Context;
string bundleUrlFromContext = context.Request.AppRelativeCurrentExecutionFilePath + context.Request.PathInfo;
var bundle = BundleTable.GetBundleFor(bundleUrlFromContext);
if (bundle != null)
{
context.RemapHandler(new BundleHandler(bundle, bundleUrlFromContext));
return true;
}
return false;
}
}
}