Exemplo n.º 1
0
        private static HttpConfiguration CreateHttpCfg(RavenDBOptions options)
        {
            var cfg = new HttpConfiguration();

            cfg.Properties[typeof(DatabasesLandlord)]          = options.DatabaseLandlord;
            cfg.Properties[typeof(FileSystemsLandlord)]        = options.FileSystemLandlord;
            cfg.Properties[typeof(CountersLandlord)]           = options.CountersLandlord;
            cfg.Properties[typeof(MixedModeRequestAuthorizer)] = options.MixedModeRequestAuthorizer;
            cfg.Properties[typeof(RequestManager)]             = options.RequestManager;
            cfg.Properties[Constants.MaxConcurrentRequestsForDatabaseDuringLoad] = new SemaphoreSlim(options.SystemDatabase.Configuration.MaxConcurrentRequestsForDatabaseDuringLoad);
            cfg.Properties[Constants.MaxSecondsForTaskToWaitForDatabaseToLoad]   = options.SystemDatabase.Configuration.MaxSecondsForTaskToWaitForDatabaseToLoad;
            cfg.Formatters.Remove(cfg.Formatters.XmlFormatter);
            cfg.Formatters.JsonFormatter.SerializerSettings.Converters.Add(new NaveValueCollectionJsonConverterOnlyForConfigFormatters());
            cfg.Services.Replace(typeof(IAssembliesResolver), new RavenAssemblyResolver());
            cfg.Filters.Add(new RavenExceptionFilterAttribute());

            cfg.MessageHandlers.Add(new ThrottlingHandler(options.SystemDatabase.Configuration.MaxConcurrentServerRequests));
            cfg.MessageHandlers.Add(new GZipToJsonAndCompressHandler());

            cfg.Services.Replace(typeof(IHostBufferPolicySelector), new SelectiveBufferPolicySelector());

            if (RouteCacher.TryAddRoutesFromCache(cfg) == false)
            {
                AddRoutes(cfg);
            }

            cfg.EnsureInitialized();

            RouteCacher.CacheRoutesIfNecessary(cfg);

            return(cfg);
        }
Exemplo n.º 2
0
        protected AuthorizationTest()
        {
            RouteCacher.ClearCache();

            server = GetNewServer(configureConfig: configuration => configuration.Catalog.Catalogs.Add(new AssemblyCatalog(typeof(AuthorizationDecisions).Assembly)));
            store  = NewRemoteDocumentStore(ravenDbServer: server, databaseName: DatabaseName);

            foreach (DictionaryEntry de in HttpRuntime.Cache)
            {
                HttpRuntime.Cache.Remove((string)de.Key);
            }
        }