Ejemplo n.º 1
0
        public static HostConfig NewInstance()
        {
            var config = new HostConfig
            {
                WsdlServiceNamespace      = DefaultWsdlNamespace,
                ApiVersion                = "1.0",
                EmbeddedResourceSources   = new List <Assembly>(),
                EmbeddedResourceBaseTypes = new[] { HostContext.AppHost.GetType(), typeof(Service) }.ToList(),
                EmbeddedResourceTreatAsFiles = new HashSet <string>(),
                LogFactory = new NullLogFactory(),
                EnableAccessRestrictions = true,
                WebHostPhysicalPath      = "~".MapServerPath(),
                HandlerFactoryPath       = ServiceStackPath,
                MetadataRedirectPath     = null,
                DefaultContentType       = null,
                PreferredContentTypes    = new List <string> {
                    MimeTypes.Html, MimeTypes.Json, MimeTypes.Xml, MimeTypes.Jsv
                },
                AllowJsonpRequests = true,
                AllowRouteContentTypeExtensions = true,
                AllowNonHttpOnlyCookies         = false,
                UseHttpsLinks    = false,
                DebugMode        = false,
                DefaultDocuments = new List <string> {
                    "default.htm",
                    "default.html",
                    "default.cshtml",
                    "default.md",
                    "index.htm",
                    "index.html",
                    "default.aspx",
                    "default.ashx",
                },
                GlobalResponseHeaders = new Dictionary <string, string> {
                    { "Vary", "Accept" },
                    { "X-Powered-By", Env.ServerUserAgent },
                },
                IgnoreFormatsInMetadata = new HashSet <string>(StringComparer.OrdinalIgnoreCase),
                AllowFileExtensions     = new HashSet <string>(StringComparer.OrdinalIgnoreCase)
                {
                    "js", "ts", "jsx", "css", "htm", "html", "shtm", "txt", "xml", "rss", "csv", "pdf",
                    "jpg", "jpeg", "gif", "png", "bmp", "ico", "tif", "tiff", "svg",
                    "avi", "divx", "m3u", "mov", "mp3", "mpeg", "mpg", "qt", "vob", "wav", "wma", "wmv",
                    "flv", "swf", "xap", "xaml", "ogg", "mp4", "webm", "eot", "ttf", "woff", "woff2", "map"
                },
                DebugAspNetHostEnvironment       = Env.IsMono ? "FastCGI" : "IIS7",
                DebugHttpListenerHostEnvironment = Env.IsMono ? "XSP" : "WebServer20",
                EnableFeatures              = Feature.All,
                WriteErrorsToResponse       = true,
                ReturnsInnerException       = true,
                DisposeDependenciesAfterUse = true,
                MarkdownOptions             = new MarkdownOptions(),
                MarkdownBaseType            = typeof(MarkdownViewBase),
                MarkdownGlobalHelpers       = new Dictionary <string, Type>(),
                HtmlReplaceTokens           = new Dictionary <string, string>(),
                AddMaxAgeForStaticMimeTypes = new Dictionary <string, TimeSpan> {
                    { "image/gif", TimeSpan.FromHours(1) },
                    { "image/png", TimeSpan.FromHours(1) },
                    { "image/jpeg", TimeSpan.FromHours(1) },
                },
                AppendUtf8CharsetOnContentTypes = new HashSet <string> {
                    MimeTypes.Json,
                },
                RouteNamingConventions = new List <RouteNamingConventionDelegate> {
                    RouteNamingConvention.WithRequestDtoName,
                    RouteNamingConvention.WithMatchingAttributes,
                    RouteNamingConvention.WithMatchingPropertyNames
                },
                MapExceptionToStatusCode           = new Dictionary <Type, int>(),
                OnlySendSessionCookiesSecurely     = false,
                AllowSessionIdsInHttpParams        = false,
                RestrictAllCookiesToDomain         = null,
                DefaultJsonpCacheExpiration        = new TimeSpan(0, 20, 0),
                MetadataVisibility                 = RequestAttributes.Any,
                Return204NoContentForEmptyResponse = true,
                AllowPartialResponses              = true,
                AllowAclUrlReservation             = true,
                AddRedirectParamsToQueryString     = false,
                RedirectToDefaultDocuments         = false,
                StripApplicationVirtualPath        = false,
                ScanSkipPaths = new List <string> {
                    "/obj/",
                    "/bin/",
                    "/node_modules/",
                    "/bower_components/",
                    "/wwwroot/",
                    "/wwwroot_build/",
                },
                IgnoreWarningsOnPropertyNames = new List <string> {
                    Keywords.Format, Keywords.Callback, Keywords.Debug, Keywords.AuthSecret,
                    Keywords.IgnorePlaceHolder, Keywords.Version, Keywords.VersionAbbr, Keywords.Version.ToPascalCase(),
                },
                XmlWriterSettings = new XmlWriterSettings
                {
                    Encoding = new UTF8Encoding(encoderShouldEmitUTF8Identifier: false),
                }
            };

            if (config.HandlerFactoryPath == null)
            {
                config.InferHttpHandlerPath();
            }

            return(config);
        }
Ejemplo n.º 2
0
        public static HostConfig NewInstance()
        {
            var config = new HostConfig
            {
                MetadataTypesConfig     = new MetadataTypesConfig(addDefaultXmlNamespace: "http://schemas.servicestack.net/types"),
                WsdlServiceNamespace    = "http://schemas.servicestack.net/types",
                EmbeddedResourceSources = new[] { HostContext.AppHost.GetType().Assembly, typeof(Service).Assembly }.ToList(),
                LogFactory = new NullLogFactory(),
                EnableAccessRestrictions        = true,
                WebHostPhysicalPath             = "~".MapServerPath(),
                HandlerFactoryPath              = ServiceStackPath,
                MetadataRedirectPath            = null,
                DefaultContentType              = null,
                AllowJsonpRequests              = true,
                AllowRouteContentTypeExtensions = true,
                AllowNonHttpOnlyCookies         = false,
                UseHttpsLinks    = false,
                DebugMode        = false,
                DefaultDocuments = new List <string> {
                    "default.htm",
                    "default.html",
                    "default.cshtml",
                    "default.md",
                    "index.htm",
                    "index.html",
                    "default.aspx",
                    "default.ashx",
                },
                GlobalResponseHeaders = new Dictionary <string, string> {
                    { "X-Powered-By", Env.ServerUserAgent }
                },
                IgnoreFormatsInMetadata = new HashSet <string>(StringComparer.InvariantCultureIgnoreCase),
                AllowFileExtensions     = new HashSet <string>(StringComparer.InvariantCultureIgnoreCase)
                {
                    "js", "css", "htm", "html", "shtm", "txt", "xml", "rss", "csv", "pdf",
                    "jpg", "jpeg", "gif", "png", "bmp", "ico", "tif", "tiff", "svg",
                    "avi", "divx", "m3u", "mov", "mp3", "mpeg", "mpg", "qt", "vob", "wav", "wma", "wmv",
                    "flv", "xap", "xaml", "ogg", "mp4", "webm", "eot", "ttf", "woff"
                },
                DebugAspNetHostEnvironment       = Env.IsMono ? "FastCGI" : "IIS7",
                DebugHttpListenerHostEnvironment = Env.IsMono ? "XSP" : "WebServer20",
                EnableFeatures              = Feature.All,
                WriteErrorsToResponse       = true,
                ReturnsInnerException       = true,
                MarkdownOptions             = new MarkdownOptions(),
                MarkdownBaseType            = typeof(MarkdownViewBase),
                MarkdownGlobalHelpers       = new Dictionary <string, Type>(),
                HtmlReplaceTokens           = new Dictionary <string, string>(),
                AddMaxAgeForStaticMimeTypes = new Dictionary <string, TimeSpan> {
                    { "image/gif", TimeSpan.FromHours(1) },
                    { "image/png", TimeSpan.FromHours(1) },
                    { "image/jpeg", TimeSpan.FromHours(1) },
                },
                AppendUtf8CharsetOnContentTypes = new HashSet <string> {
                    MimeTypes.Json,
                },
                RouteNamingConventions = new List <RouteNamingConventionDelegate> {
                    RouteNamingConvention.WithRequestDtoName,
                    RouteNamingConvention.WithMatchingAttributes,
                    RouteNamingConvention.WithMatchingPropertyNames
                },
                GlobalHtmlErrorHttpHandler         = null,
                MapExceptionToStatusCode           = new Dictionary <Type, int>(),
                OnlySendSessionCookiesSecurely     = false,
                RestrictAllCookiesToDomain         = null,
                DefaultJsonpCacheExpiration        = new TimeSpan(0, 20, 0),
                MetadataVisibility                 = RequestAttributes.Any,
                Return204NoContentForEmptyResponse = true,
                AllowPartialResponses              = true,
                AllowAclUrlReservation             = true,
                RedirectToDefaultDocuments         = false,
                StripApplicationVirtualPath        = false,
                ScanSkipPaths = new List <string> {
                    "/obj/",
                    "/bin/",
                },
                IgnoreWarningsOnPropertyNames = new List <string> {
                    "format", "callback", "debug", "_", "authsecret"
                }
            };

            if (config.HandlerFactoryPath == null)
            {
                config.InferHttpHandlerPath();
            }

            return(config);
        }
Ejemplo n.º 3
0
        public static HostConfig NewInstance()
        {
            var config = new HostConfig
            {
                WsdlServiceNamespace = DefaultWsdlNamespace,
                ApiVersion = "1.0",
                EmbeddedResourceSources = new List<Assembly>(),
                EmbeddedResourceBaseTypes = new[] { HostContext.AppHost.GetType(), typeof(Service) }.ToList(),
                LogFactory = new NullLogFactory(),
                EnableAccessRestrictions = true,
                WebHostPhysicalPath = "~".MapServerPath(),
                HandlerFactoryPath = ServiceStackPath,
                MetadataRedirectPath = null,
                DefaultContentType = null,
                PreferredContentTypes = new List<string> {
                    MimeTypes.Html, MimeTypes.Json, MimeTypes.Xml, MimeTypes.Jsv
                },
                AllowJsonpRequests = true,
                AllowRouteContentTypeExtensions = true,
                AllowNonHttpOnlyCookies = false,
                UseHttpsLinks = false,
                DebugMode = false,
                DefaultDocuments = new List<string> {
	                "default.htm",
	                "default.html",
	                "default.cshtml",
	                "default.md",
	                "index.htm",
	                "index.html",
	                "default.aspx",
	                "default.ashx",
                },
                GlobalResponseHeaders = new Dictionary<string, string> {
                    { "Vary", "Accept" },
                    { "X-Powered-By", Env.ServerUserAgent },
                },
                IgnoreFormatsInMetadata = new HashSet<string>(StringComparer.OrdinalIgnoreCase),
                AllowFileExtensions = new HashSet<string>(StringComparer.OrdinalIgnoreCase)
                {
                    "js", "css", "htm", "html", "shtm", "txt", "xml", "rss", "csv", "pdf",  
                    "jpg", "jpeg", "gif", "png", "bmp", "ico", "tif", "tiff", "svg",
                    "avi", "divx", "m3u", "mov", "mp3", "mpeg", "mpg", "qt", "vob", "wav", "wma", "wmv", 
                    "flv", "swf", "xap", "xaml", "ogg", "mp4", "webm", "eot", "ttf", "woff", "map"
                },
                DebugAspNetHostEnvironment = Env.IsMono ? "FastCGI" : "IIS7",
                DebugHttpListenerHostEnvironment = Env.IsMono ? "XSP" : "WebServer20",
                EnableFeatures = Feature.All,
                WriteErrorsToResponse = true,
                ReturnsInnerException = true,
                MarkdownOptions = new MarkdownOptions(),
                MarkdownBaseType = typeof(MarkdownViewBase),
                MarkdownGlobalHelpers = new Dictionary<string, Type>(),
                HtmlReplaceTokens = new Dictionary<string, string>(),
                AddMaxAgeForStaticMimeTypes = new Dictionary<string, TimeSpan> {
		            { "image/gif", TimeSpan.FromHours(1) },
		            { "image/png", TimeSpan.FromHours(1) },
		            { "image/jpeg", TimeSpan.FromHours(1) },
	            },
                AppendUtf8CharsetOnContentTypes = new HashSet<string> { MimeTypes.Json, },
                RouteNamingConventions = new List<RouteNamingConventionDelegate> {
		            RouteNamingConvention.WithRequestDtoName,
		            RouteNamingConvention.WithMatchingAttributes,
		            RouteNamingConvention.WithMatchingPropertyNames
                },
                MapExceptionToStatusCode = new Dictionary<Type, int>(),
                OnlySendSessionCookiesSecurely = false,
                RestrictAllCookiesToDomain = null,
                DefaultJsonpCacheExpiration = new TimeSpan(0, 20, 0),
                MetadataVisibility = RequestAttributes.Any,
                Return204NoContentForEmptyResponse = true,
                AllowPartialResponses = true,
                AllowAclUrlReservation = true,
                RedirectToDefaultDocuments = false,
                StripApplicationVirtualPath = false,
                ScanSkipPaths = new List<string> {
                    "/obj/", 
                    "/bin/",
                },
                IgnoreWarningsOnPropertyNames = new List<string> {
                    "format", "callback", "debug", "_", "authsecret"
                }
            };

            if (config.HandlerFactoryPath == null)
            {
                config.InferHttpHandlerPath();
            }

            return config;
        }
Ejemplo n.º 4
0
        public static HostConfig NewInstance()
        {
            var config = new HostConfig
            {
                MetadataTypesConfig = new MetadataTypesConfig(addDefaultXmlNamespace: "http://schemas.servicestack.net/types"),
                WsdlServiceNamespace = "http://schemas.servicestack.net/types",
                MetadataPageBodyHtml = @"<br />
                    <h3><a href=""https://github.com/ServiceStack/ServiceStack/wiki/Clients-overview"">Clients Overview</a></h3>",
                MetadataOperationPageBodyHtml = @"<br />
                    <h3><a href=""https://github.com/ServiceStack/ServiceStack/wiki/Clients-overview"">Clients Overview</a></h3>",
                MetadataCustomPath = "Views/Templates/Metadata/",
                UseCustomMetadataTemplates = false,
                LogFactory = new NullLogFactory(),
                EnableAccessRestrictions = true,
                WebHostPhysicalPath = "~".MapServerPath(),
                ServiceStackHandlerFactoryPath = ServiceStackPath,
                MetadataRedirectPath = null,
                DefaultContentType = null,
                AllowJsonpRequests = true,
                AllowRouteContentTypeExtensions = true,
                AllowNonHttpOnlyCookies = false,
                UseHttpsLinks = false,
                DebugMode = false,
                DefaultDocuments = new List<string> {
					"default.htm",
					"default.html",
					"default.cshtml",
					"default.md",
					"index.htm",
					"index.html",
					"default.aspx",
					"default.ashx",
				},
                GlobalResponseHeaders = new Dictionary<string, string> { { "X-Powered-By", Env.ServerUserAgent } },
                IgnoreFormatsInMetadata = new HashSet<string>(StringComparer.InvariantCultureIgnoreCase),
                AllowFileExtensions = new HashSet<string>(StringComparer.InvariantCultureIgnoreCase)
				{
					"js", "css", "htm", "html", "shtm", "txt", "xml", "rss", "csv", "pdf",  
					"jpg", "jpeg", "gif", "png", "bmp", "ico", "tif", "tiff", "svg",
					"avi", "divx", "m3u", "mov", "mp3", "mpeg", "mpg", "qt", "vob", "wav", "wma", "wmv", 
					"flv", "xap", "xaml", "ogg", "mp4", "webm", "eot", "ttf", "woff"
				},
                DebugAspNetHostEnvironment = Env.IsMono ? "FastCGI" : "IIS7",
                DebugHttpListenerHostEnvironment = Env.IsMono ? "XSP" : "WebServer20",
                EnableFeatures = Feature.All,
                WriteErrorsToResponse = true,
                ReturnsInnerException = true,
                MarkdownOptions = new MarkdownOptions(),
                MarkdownBaseType = typeof(MarkdownViewBase),
                MarkdownGlobalHelpers = new Dictionary<string, Type>(),
                HtmlReplaceTokens = new Dictionary<string, string>(),
                AddMaxAgeForStaticMimeTypes = new Dictionary<string, TimeSpan> {
					{ "image/gif", TimeSpan.FromHours(1) },
					{ "image/png", TimeSpan.FromHours(1) },
					{ "image/jpeg", TimeSpan.FromHours(1) },
				},
                AppendUtf8CharsetOnContentTypes = new HashSet<string> { MimeTypes.Json, },
                RawHttpHandlers = new List<Func<IHttpRequest, IHttpHandler>>(),
                RouteNamingConventions = new List<RouteNamingConventionDelegate> {
					RouteNamingConvention.WithRequestDtoName,
					RouteNamingConvention.WithMatchingAttributes,
					RouteNamingConvention.WithMatchingPropertyNames
                },
                CustomHttpHandlers = new Dictionary<HttpStatusCode, IServiceStackHttpHandler>(),
                GlobalHtmlErrorHttpHandler = null,
                MapExceptionToStatusCode = new Dictionary<Type, int>(),
                OnlySendSessionCookiesSecurely = false,
                RestrictAllCookiesToDomain = null,
                DefaultJsonpCacheExpiration = new TimeSpan(0, 20, 0),
                MetadataVisibility = RequestAttributes.Any,
                Return204NoContentForEmptyResponse = true,
                AllowPartialResponses = true,
                AllowAclUrlReservation = true,
                IgnoreWarningsOnPropertyNames = new List<string> {
                    "format", "callback", "debug", "_", "authsecret"
                }
            };

            if (config.ServiceStackHandlerFactoryPath == null)
            {
                config.InferHttpHandlerPath();
            }

            return config;
        }