Exemple #1
0
        protected async override Task<HttpResponseMessage> SendAsync(HttpRequestMessage request, System.Threading.CancellationToken cancellationToken)
        {



            return await Task.Run(() =>
            {

                var metadata = _metadataProvider.GetMetadata(request);

                if (request.Headers.Any(h => h.Key == "X-Proxy-Type" && h.Value.Contains("metadata")))
                    return request.CreateResponse(System.Net.HttpStatusCode.OK, metadata);


                var template = new JsProxyTemplate(metadata);
                var js = new StringContent(template.TransformText());

                js.Headers.ContentType = new MediaTypeHeaderValue("application/javascript");

                return new HttpResponseMessage { Content = js }; ;





            });

        }
        protected async override Task<HttpResponseMessage> SendAsync(HttpRequestMessage request, System.Threading.CancellationToken cancellationToken)
        {
            return await Task.Run(() =>
            {
                var metadata = _metadataProvider.GetMetadata(request);
                string exportCallback = "null";

                if (request.Headers.Any(h => h.Key == "X-Proxy-Type" && h.Value.Contains("metadata")))
                {
                    return request.CreateResponse(System.Net.HttpStatusCode.OK, metadata);
                }
                
                var template = new JsProxyTemplate(metadata)
                {
                    ExportCallback = this.ExportCallback
                };
                var js = new StringContent(template.TransformText());

                js.Headers.ContentType = new MediaTypeHeaderValue("application/javascript");
                js.Headers.Expires = DateTime.Now.AddDays(30).ToUniversalTime();

                var result = new HttpResponseMessage { Content = js }; ;
                result.Headers.CacheControl = CacheControlHeaderValue.Parse("public");
                
                return result;
            });
        }