Example #1
0
        public IResponse?Handle(IRequest request)
        {
            string?sitemapUrl = null;

            if (Sitemap != null)
            {
                if (!Sitemap.StartsWith("http"))
                {
                    var protocol = request.Client.Protocol.ToString().ToLower();

                    var normalized = Sitemap.StartsWith("/") ? Sitemap.Substring(1) : Sitemap;

                    sitemapUrl = $"{protocol}://{request.Host}/{normalized}";
                }
                else
                {
                    sitemapUrl = Sitemap;
                }
            }

            return(request.Respond()
                   .Type(ContentType.TextPlain)
                   .Content(new RobotsContent(Directives, sitemapUrl))
                   .Build());
        }