/// <summary> /// Callback used to handle a pending request from a client. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected virtual void PendingRequestCallback(object sender, ResourceExecutionContextEventArgs e) { Trace.WriteLine("Processing request"); var request = e.Context.Request; var response = e.Context.Response; Resource res = null; var segs = request.Url.Segments; ResourceGraphNode node = this.resources.Root; foreach (var seg in segs.Skip(1)) { node = node.FirstOrDefault(n => n.SegmentName == seg); if (node == null) break; } if (node != null) res = node.Resource; if (res == null) { response.Status = StatusCode.Http404NotFound; } else { response.Status = StatusCode.Http200Ok; res.OnRequest(request, response); response.ContentType = res.ContentType; } }
protected virtual void OnContextPending(ResourceExecutionContextEventArgs e) { if (this.ContextPending != null) this.ContextPending(this, e); }