コード例 #1
0
        public Task Invoke(IDictionary<string, object> environment)
        {
            var path = environment[OwinConstants.RequestPathKey].As<string>().TrimStart('/');

            if (path == "topics.js")
            {
                return Task.Factory.StartNew(() =>
                {
                    var response = new OwinHttpResponse(environment);
                    response.WriteContentType("text/javascript");
                    new AssetSettings().Headers.Each((key, func) => response.AppendHeader(key, func()));
                    response.Write(_topicJS);

                    response.Flush();
                });
            }

            var topic = _project.FindTopicByUrl(path);
            if (topic == null)
            {
                return _inner(environment);
            }

            return Task.Factory.StartNew(() =>
            {
                var response = new OwinHttpResponse(environment);
                response.WriteContentType("text/html");

                var html = GenerateHtml(topic);

                response.Write(html);
                response.Flush();
            });
        }
コード例 #2
0
ファイル: FubuOwinHost.cs プロジェクト: DarthFubuMVC/fubumvc
        private void write500(IDictionary<string, object> environment, Exception exception)
        {
            using (var writer = new OwinHttpResponse(environment))
            {
                writer.WriteResponseCode(HttpStatusCode.InternalServerError);
                var document = new HtmlDocument
                {
                    Title = "Exception!"
                };

                document.Add("h1").Text("FubuMVC has detected an exception");
                document.Add("hr");
                document.Add("pre").Id("error").Text(exception.ToString());

                writer.WriteContentType(MimeType.Html.Value);
                writer.Write(document.ToString());
            }
        }
コード例 #3
0
        public Task Invoke(IDictionary<string, object> environment)
        {
            var path = environment[OwinConstants.RequestPathKey].As<string>().TrimStart('/');

            if (path == "topics.js")
            {
                return Task.Factory.StartNew(() =>
                {
                    var response = new OwinHttpResponse(environment);
                    response.WriteContentType("text/javascript");

                    response.Write(_topicJS);


                   
                    response.Flush();
                });
            }

            var topic = _project.FindTopicByUrl(path);
            if (topic == null)
            {
                return _inner(environment);
            }

            return Task.Factory.StartNew(() =>
            {
                var response = new OwinHttpResponse(environment);
                response.WriteContentType("text/html");

                response.AppendHeader(HttpGeneralHeaders.CacheControl, "no-cache, no-store, must-revalidate");
                response.AppendHeader(HttpResponseHeaders.Pragma, "no-cache");
                response.AppendHeader(HttpResponseHeaders.Expires, "0");


                var html = GenerateHtml(topic);


                response.Write(html);
                response.Flush();
            });

        }
コード例 #4
0
        public Task Invoke(IDictionary <string, object> environment)
        {
            var path = environment[OwinConstants.RequestPathKey].As <string>().TrimStart('/');

            if (path == "topics.js")
            {
                return(Task.Factory.StartNew(() =>
                {
                    var response = new OwinHttpResponse(environment);
                    response.WriteContentType("text/javascript");

                    response.Write(_topicJS);



                    response.Flush();
                }));
            }

            var topic = _project.FindTopicByUrl(path);

            if (topic == null)
            {
                return(_inner(environment));
            }

            return(Task.Factory.StartNew(() =>
            {
                var response = new OwinHttpResponse(environment);
                response.WriteContentType("text/html");

                response.AppendHeader(HttpGeneralHeaders.CacheControl, "no-cache, no-store, must-revalidate");
                response.AppendHeader(HttpResponseHeaders.Pragma, "no-cache");
                response.AppendHeader(HttpResponseHeaders.Expires, "0");


                var html = GenerateHtml(topic);


                response.Write(html);
                response.Flush();
            }));
        }
コード例 #5
0
        public Task Invoke(IDictionary <string, object> environment)
        {
            var path = environment[OwinConstants.RequestPathKey].As <string>().TrimStart('/');

            if (path == "topics.js")
            {
                return(Task.Factory.StartNew(() =>
                {
                    var response = new OwinHttpResponse(environment);
                    response.WriteContentType("text/javascript");
                    new AssetSettings().Headers.Each((key, func) => response.AppendHeader(key, func()));
                    response.Write(_topicJS);

                    response.Flush();
                }));
            }

            var topic = _project.FindTopicByUrl(path);

            if (topic == null)
            {
                return(_inner(environment));
            }

            return(Task.Factory.StartNew(() =>
            {
                var response = new OwinHttpResponse(environment);
                response.WriteContentType("text/html");

                var html = GenerateHtml(topic);


                response.Write(html);
                response.Flush();
            }));
        }