using System; using System.Collections.Generic; namespace ln.http.resources { public class ResourceApplication : HttpApplication { public Resource RootResource { get; set; } public ResourceApplication() { RootResource = new BaseResource(""); } public override HttpResponse GetResponse(HttpRequest httpRequest) { /* TODO: Implement Authentication here... */ Resource currentResource = RootResource; Queue pathStack = new Queue(httpRequest.URI.AbsolutePath.Split(new String[] { "/" }, StringSplitOptions.RemoveEmptyEntries)); while ((pathStack.Count > 0) && (!currentResource.HandlesDispatching)) { String next = pathStack.Dequeue(); if (!currentResource.Contains(next)) throw new KeyNotFoundException(); currentResource = currentResource.GetResource(next); /* TODO: Implement Authorization hook here... */ } return currentResource.GetResponse(httpRequest,pathStack); } } }