public override void Configure(Container container) { IocShared.Configure(this); JsConfig.EmitCamelCaseNames = true; this.PreRequestFilters.Add((req, res) => { req.Items["_DataSetAtPreRequestFilters"] = true; }); this.GlobalRequestFilters.Add((req, res, dto) => { req.Items["_DataSetAtRequestFilters"] = true; var requestFilter = dto as RequestFilter; if (requestFilter != null) { res.StatusCode = requestFilter.StatusCode; if (!requestFilter.HeaderName.IsNullOrEmpty()) { res.AddHeader(requestFilter.HeaderName, requestFilter.HeaderValue); } res.Close(); } var secureRequests = dto as IRequiresSession; if (secureRequests != null) { res.ReturnAuthRequired(); } }); this.Container.Register <IDbConnectionFactory>(c => new OrmLiteConnectionFactory( "~/App_Data/db.sqlite".MapHostAbsolutePath(), SqliteDialect.Provider) { ConnectionFilter = x => new ProfiledDbConnection(x, Profiler.Current) }); this.Container.Register <ICacheClient>(new MemoryCacheClient()); //this.Container.Register<ICacheClient>(new BasicRedisClientManager()); ConfigureAuth(container); //this.Container.Register<ISessionFactory>( // c => new SessionFactory(c.Resolve<ICacheClient>())); var dbFactory = this.Container.Resolve <IDbConnectionFactory>(); using (var db = dbFactory.Open()) db.DropAndCreateTable <Movie>(); ModelConfig <Movie> .Id(x => x.Title); Routes .Add <Movies>("/custom-movies", "GET, OPTIONS") .Add <Movies>("/custom-movies/genres/{Genre}") .Add <Movie>("/custom-movies", "POST,PUT") .Add <Movie>("/custom-movies/{Id}") .Add <MqHostStats>("/mqstats"); var resetMovies = this.Container.Resolve <ResetMoviesService>(); resetMovies.Post(null); container.Register <IRedisClientsManager>(c => new RedisManagerPool()); Plugins.Add(new ValidationFeature()); Plugins.Add(new SessionFeature()); Plugins.Add(new ProtoBufFormat()); Plugins.Add(new RequestLogsFeature { RequestLogger = new RedisRequestLogger(container.Resolve <IRedisClientsManager>()) }); Plugins.Add(new SwaggerFeature { //UseBootstrapTheme = true }); Plugins.Add(new PostmanFeature()); Plugins.Add(new CorsFeature()); container.RegisterValidators(typeof(CustomersValidator).Assembly); //var onlyEnableFeatures = Feature.All.Remove(Feature.Jsv | Feature.Soap); SetConfig(new HostConfig { AdminAuthSecret = AuthTestsBase.AuthSecret, //EnableFeatures = onlyEnableFeatures, DebugMode = true, //Show StackTraces for easier debugging }); if (StartMqHost) { var redisManager = new BasicRedisClientManager(); var mqHost = new RedisMqServer(redisManager); mqHost.RegisterHandler <Reverse>(ServiceController.ExecuteMessage); mqHost.Start(); this.Container.Register((IMessageService)mqHost); } }
public override void Configure(Container container) { IocShared.Configure(this); JsConfig.Init(new Text.Config { TextCase = TextCase.CamelCase, }); ServiceStack.Auth.RegisterService.AllowUpdates = true; this.PreRequestFilters.Add((req, res) => { req.Items["_DataSetAtPreRequestFilters"] = true; }); this.GlobalRequestFilters.Add((req, res, dto) => { req.Items["_DataSetAtRequestFilters"] = true; if (dto is RequestFilter requestFilter) { res.StatusCode = requestFilter.StatusCode; if (!requestFilter.HeaderName.IsNullOrEmpty()) { res.AddHeader(requestFilter.HeaderName, requestFilter.HeaderValue); } res.Close(); } if (dto is IRequiresSession secureRequests) { res.ReturnAuthRequired(); } }); Plugins.Add(new SoapFormat()); Plugins.Add(new MiniProfilerFeature()); this.Container.Register <IDbConnectionFactory>(c => new OrmLiteConnectionFactory( "~/App_Data/db.sqlite".MapHostAbsolutePath(), SqliteDialect.Provider) { ConnectionFilter = x => new ProfiledDbConnection(x, Profiler.Current) }); this.Container.Register <ICacheClient>(new MemoryCacheClient()); //this.Container.Register<ICacheClient>(new BasicRedisClientManager()); ConfigureAuth(container); //this.Container.Register<ISessionFactory>( // c => new SessionFactory(c.Resolve<ICacheClient>())); var dbFactory = this.Container.Resolve <IDbConnectionFactory>(); using (var db = dbFactory.Open()) db.DropAndCreateTable <Movie>(); ModelConfig <Movie> .Id(x => x.Title); Routes .Add <Movies>("/custom-movies", "GET, OPTIONS") .Add <Movies>("/custom-movies/genres/{Genre}") .Add <Movie>("/custom-movies", "POST,PUT") .Add <Movie>("/custom-movies/{Id}") .Add <MqHostStats>("/mqstats"); var resetMovies = this.Container.Resolve <ResetMoviesService>(); resetMovies.Post(null); container.Register <IRedisClientsManager>(c => new RedisManagerPool()); Plugins.Add(new TemplatePagesFeature()); Plugins.Add(new ValidationFeature()); Plugins.Add(new SessionFeature()); Plugins.Add(new ProtoBufFormat()); Plugins.Add(new RequestLogsFeature { //RequestLogger = new RedisRequestLogger(container.Resolve<IRedisClientsManager>()) RequestLogger = new CsvRequestLogger(), }); Plugins.Add(new OpenApiFeature { }); Plugins.Add(new PostmanFeature()); Plugins.Add(new CorsFeature()); Plugins.Add(new AutoQueryFeature { MaxLimit = 100 }); //Plugins.Add(new AdminFeature()); container.RegisterValidators(typeof(CustomersValidator).Assembly); typeof(ResponseStatus) .AddAttributes(new ServiceStack.DataAnnotations.DescriptionAttribute("This is the Response Status!")); typeof(ResponseStatus) .GetProperty("Message") .AddAttributes(new ServiceStack.DataAnnotations.DescriptionAttribute("A human friendly error message")); //var onlyEnableFeatures = Feature.All.Remove(Feature.Jsv | Feature.Soap); SetConfig(new HostConfig { AdminAuthSecret = AuthTestsBase.AuthSecret, ApiVersion = "0.2.0", //EnableFeatures = onlyEnableFeatures, DebugMode = true, //Show StackTraces for easier debugging RedirectPaths = { { "/swagger-ui", "/swagger-ui/" } } }); if (StartMqHost) { var redisManager = new BasicRedisClientManager(); var mqHost = new RedisMqServer(redisManager); mqHost.RegisterHandler <Reverse>(ExecuteMessage); mqHost.Start(); this.Container.Register((IMessageService)mqHost); } }
public override void Configure(Container container) { IocShared.Configure(this); }
public override void Configure(Funq.Container container) { IocShared.Configure(this); this.PreRequestFilters.Add((req, res) => { req.Items["_DataSetAtPreRequestFilters"] = true; }); this.GlobalRequestFilters.Add((req, res, dto) => { req.Items["_DataSetAtRequestFilters"] = true; if (dto is RequestFilter requestFilter) { res.StatusCode = requestFilter.StatusCode; if (!requestFilter.HeaderName.IsNullOrEmpty()) { res.AddHeader(requestFilter.HeaderName, requestFilter.HeaderValue); } res.Close(); } if (dto is IRequiresSession secureRequests) { res.ReturnAuthRequired(); } }); Plugins.Add(new SoapFormat()); Plugins.Add(new MiniProfilerFeature()); container.Register <IDbConnectionFactory>(c => new OrmLiteConnectionFactory( "~/App_Data/db.sqlite".MapHostAbsolutePath(), SqliteDialect.Provider) { ConnectionFilter = x => new ProfiledDbConnection(x, Profiler.Current) }); container.Register <ICacheClient>(new MemoryCacheClient()); //container.Register<ICacheClient>(new BasicRedisClientManager()); ConfigureAuth(container); //container.Register<ISessionFactory>( // c => new SessionFactory(c.Resolve<ICacheClient>())); var dbFactory = container.Resolve <IDbConnectionFactory>(); using (var db = dbFactory.Open()) db.DropAndCreateTable <Movie>(); ModelConfig <Movie> .Id(x => x.Title); Routes .Add <Movies>("/custom-movies", "GET, OPTIONS") .Add <Movies>("/custom-movies/genres/{Genre}") .Add <Movie>("/custom-movies", "POST,PUT") .Add <Movie>("/custom-movies/{Id}") .Add <MqHostStats>("/mqstats"); container.Register <IRedisClientsManager>(c => new RedisManagerPool()); Plugins.Add(new TemplatePagesFeature()); Plugins.Add(new ValidationFeature()); Plugins.Add(new SessionFeature()); Plugins.Add(new ProtoBufFormat()); Plugins.Add(new RequestLogsFeature { //RequestLogger = new RedisRequestLogger(container.Resolve<IRedisClientsManager>()) RequestLogger = new CsvRequestLogger(), }); Plugins.Add(new SwaggerFeature { //UseBootstrapTheme = true OperationFilter = x => x.Consumes = x.Produces = new[] { MimeTypes.Json, MimeTypes.Xml }.ToList(), RouteSummary = { { "/swaggerexamples", "Swagger Examples Summary" } } }); Plugins.Add(new PostmanFeature()); Plugins.Add(new CorsFeature()); Plugins.Add(new AutoQueryFeature { MaxLimit = 100 }); Plugins.Add(new AdminFeature()); container.RegisterValidators(typeof(CustomersValidator).Assembly); typeof(ResponseStatus) .AddAttributes(new DescriptionAttribute("This is the Response Status!")); typeof(ResponseStatus) .GetProperty("Message") .AddAttributes(new DescriptionAttribute("A human friendly error message")); if (StartMqHost) { var redisManager = new BasicRedisClientManager(); var mqHost = new RedisMqServer(redisManager); mqHost.RegisterHandler <Reverse>(ExecuteMessage); mqHost.Start(); container.Register((IMessageService)mqHost); } }