Пример #1
0
        public void ConfigureAppHost(ServiceStackHost appHost, Container container, HostConfig config)
        {
            config.EmbeddedResourceSources.Add(typeof(AppHostRuntime).Assembly);
            config.AllowFileExtensions.Add("tag"); // for RiotJS
            appHost.SetConfig(config);

            //Add some default plugins
            appHost.Plugins.Add(new CorsFeature());
            appHost.Plugins.Add(new PostmanFeature());
        }
        public static void ConfigureServiceHost(this ServiceStackHost appHost, bool debugEnabled)
        {
            appHost.SetConfig(new HostConfig
            {
                DebugMode                = debugEnabled,
                DefaultRedirectPath      = "/metadata",
                MapExceptionToStatusCode = SetupExceptionToStatusCodeMap()
            });

            SetupJsonResponses();
        }
Пример #3
0
        public static void ConfigureServiceHost <TServiceHost>(this ServiceStackHost appHost, bool debugEnabled)
            where TServiceHost : ServiceStackHost
        {
            appHost.SetConfig(new HostConfig
            {
                DebugMode                = debugEnabled,
                DefaultRedirectPath      = "/metadata",
                MapExceptionToStatusCode = SetupExceptionToStatusCodeMap()
            });

            appHost.Container.AddSingleton <IRecorder>(new Recorder <TServiceHost>());
            SetupExceptionShielding(appHost);
            SetupJsonResponses();
            appHost.RegisterService <HealthCheckService>();
        }
Пример #4
0
        public static void Configure(ServiceStackHost appHost, Container container)
        {
            var appSettings = new AppSettings();

            var auth = new AuthFeature(() => new CustomUserSession(),
                                       new IAuthProvider[]
            {
                new CustomBasicAuthProvider(),
                new CredentialsAuthProvider(appSettings)
                {
                    SessionExpiry = TimeSpan.FromMinutes(30)
                }
            },
                                       "/login")
            {
                GenerateNewSessionCookiesOnAuthentication = false,
            };

            appHost.Plugins.Add(auth);

            IUserAuthRepository authRepository = new InMemoryAuthRepository();
            ICacheClient        cacheClient    = new MemoryCacheClient();

            var testUser = authRepository.CreateUserAuth(new UserAuth {
                Email = "*****@*****.**"
            }, "a");


            //IoC registrations
            container.Register(cacheClient);
            container.Register(authRepository);


            var hostConfig = new HostConfig
            {
#if DEBUG || STAGING || UAT
                DebugMode = true,
#endif
                AppendUtf8CharsetOnContentTypes = new HashSet <string> {
                    MimeTypes.Csv
                },
            };


            appHost.SetConfig(hostConfig);
        }