Example #1
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IWebHostEnvironment env, FollowerContext followerContext)
        {
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
                app.UseSwagger();
                app.UseSwaggerUI(c => c.SwaggerEndpoint("/swagger/v1/swagger.json", "FollowerService.API v1"));
            }

            followerContext.Database.Migrate();

            // var services = app.ApplicationServices.CreateScope().ServiceProvider;
            //
            // var lifeTime = services.GetService<IHostApplicationLifetime>();
            // var bus = services.GetService<IBus>();
            // lifeTime.ApplicationStarted.Register(() =>
            // {
            //     var subscriber = new AutoSubscriber(bus, "Follower");
            //     subscriber.Subscribe(Assembly.GetExecutingAssembly().GetTypes());
            //     //subscriber.SubscribeAsync(Assembly.GetExecutingAssembly().GetTypes());
            // });
            // lifeTime.ApplicationStopped.Register(() => bus.Dispose());

            app.ApplicationServices.GetRequiredService <AutoSubscriber>().SubscribeAsync(Assembly.GetExecutingAssembly().GetTypes());

            app.UseCors(x => x.AllowAnyOrigin().AllowAnyMethod().AllowAnyHeader());
            app.UseAuthentication();

            app.UseHttpsRedirection();

            app.UseRouting();

            app.UseAuthorization();

            app.UseEndpoints(endpoints => { endpoints.MapControllers(); });
        }
Example #2
0
 public FollowerController(FollowerContext context)
 {
     _context = context;
 }