Ejemplo n.º 1
0
        public void Configuration(IAppBuilder app)
        {
            app.Properties["host.AppName"] = ConfigurationManager.AppSettings["AppName"];
            app.Properties["host.AppMode"] = ConfigurationManager.AppSettings["ENV"];

            //FIXME: We need a module to load development/production mode so error pages can be turned on/off
            //Better have a global configuration module like Asp.net 5, that looked awesome!
            switch(app.Properties["host.AppMode"].ToString() )
            {
                case ("development"):
                case ("mock"):
                    app.UseErrorPage();
                    break;
            }

            AutofacContainerBuilder builder = new AutofacContainerBuilder();

            var container = builder.BuildContainer();
            app.UseAutofacMiddleware(container);

            var webApiDependencyResolver = new AutofacWebApiDependencyResolver(container);

            var config = new HttpConfiguration();

            WebApiConfig.Register(config, webApiDependencyResolver);

            app.UseCors(Microsoft.Owin.Cors.CorsOptions.AllowAll);

            app.UseWebApi(config);
            app.UseAutofacWebApi(config);

            //FIXME: Can be a small middleware. No? Alright!
            app.Run(context => {
                context.Response.ContentType = "text/plain";
                return context.Response.WriteAsync("Welcome to TaskCat, proudly baked by NerdCats");
            });

        }
Ejemplo n.º 2
0
        public void Configuration(IAppBuilder app)
        {
            app.Properties["host.AppName"] = ConfigurationManager.AppSettings["AppName"];
            app.Properties["host.AppMode"] = ConfigurationManager.AppSettings["ENV"];

            //FIXME: We need a module to load development/production mode so error pages can be turned on/off
            //Better have a global configuration module like Asp.net 5, that looked awesome!
            switch (app.Properties["host.AppMode"].ToString())
            {
            case ("development"):
            case ("mock"):
                app.UseErrorPage();
                break;
            }

            AutofacContainerBuilder builder = new AutofacContainerBuilder();

            var container = builder.BuildContainer();

            app.UseAutofacMiddleware(container);

            var webApiDependencyResolver = new AutofacWebApiDependencyResolver(container);

            var config = new HttpConfiguration();

            WebApiConfig.Register(config, webApiDependencyResolver);

            app.UseCors(Microsoft.Owin.Cors.CorsOptions.AllowAll);

            app.UseWebApi(config);
            app.UseAutofacWebApi(config);

            //FIXME: Can be a small middleware. No? Alright!
            app.Run(context => {
                context.Response.ContentType = "text/plain";
                return(context.Response.WriteAsync("Welcome to TaskCat, proudly baked by NerdCats"));
            });
        }
Ejemplo n.º 3
0
        public void Configuration(IAppBuilder app)
        {           
            var version = Assembly.GetExecutingAssembly().GetName().Version;
            app.Properties["host.AppName"] = ConfigurationManager.AppSettings["AppName"];
            app.Properties["host.AppMode"] = ConfigurationManager.AppSettings["ENV"];

            //FIXME: We need a module to load development/production mode so error pages can be turned on/off
            //Better have a global configuration module like Asp.net 5, that looked awesome!
            switch (app.Properties["host.AppMode"].ToString())
            {
                case ("development"):
                case ("mock"):
                    app.UseErrorPage();
                    break;
            }

#if DEBUG
            AppSettings.Precedence = new[] { "local", "production" };
#else
            AppSettings.Precedence = new[] { "production", "local" };
#endif

            SetupMongoConventions();

            AutofacContainerBuilder builder = new AutofacContainerBuilder();

            var container = builder.BuildContainer(app);
            app.UseAutofacMiddleware(container);
            app.Use(typeof(PreflightRequestsHandler));

            var webApiDependencyResolver = new AutofacWebApiDependencyResolver(container);

            
            var config = new HttpConfiguration();
            

            BsonSerializerConfig.Configure();           

            ConfigureOAuth(app, container);

            WebApiConfig.Register(config, webApiDependencyResolver);
            config.Filters.Add(new ErrorDocumentFilter());
            

            app.UseCors(Microsoft.Owin.Cors.CorsOptions.AllowAll);
            
            app.UseWebApi(config);
            app.UseAutofacWebApi(config);

            EmailTemplatesConfig.Configure();

            // FIXME: Need to move these with other startups
            // This is not ideal
            InitializeClients(container);
            InitializeRoles(container);

            //FIXME: Can be a small middleware. No? Alright!
            app.Run(context =>
            {
                context.Response.ContentType = "text/plain";

                return context.Response.WriteAsync(string.Format($"Welcome to TaskCat '{version}', proudly baked by NerdCats"));
            });

        }