public override async Task Handle(RequestDelegate next) { var response = string.Empty; var remoteHtml = await RemoteFetcher.GetHtml(CompositeContext.MatchString); response = await GetTemplate(next); HtmlDocument doc = new HtmlDocument(); doc.LoadHtml(response); if (remoteHtml.Head != null) { doc.DocumentNode.SelectNodes("//head")[0].PrependChild(remoteHtml.Head); } if (remoteHtml.Body != null) { doc.DocumentNode.SelectNodes("//body/div")[0].PrependChild(remoteHtml.Body); } response = doc.DocumentNode.InnerHtml; // Send our modified content to the response body. await CompositeContext.HttpContext.Response.WriteAsync(response); }
public override async Task Handle(RequestDelegate next) { var content = await RemoteFetcher.GetContent(); await CompositeContext.HttpContext.Response.WriteAsync(content); }
protected ARemoteContentHandler(CompositeContext compositeRequest) { CompositeContext = compositeRequest; RemoteFetcher = new RemoteFetcher(compositeRequest.RemotePath); }