Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Simpler Customization of Startup #368

Open
HeyJoel opened this issue Jun 1, 2020 · 0 comments
Open

Simpler Customization of Startup #368

HeyJoel opened this issue Jun 1, 2020 · 0 comments
Milestone

Comments

@HeyJoel
Copy link
Member

HeyJoel commented Jun 1, 2020

At the moment if you want to customize the startup process you need to create an implementation of one of the objects that gets used in the startup pipeline e.g. IRouteRegistration or IStartupTask. This is great for plugins and modular code, but we lack a simple way to modify the pipeline from your Startup.cs.

One example is configuring routing endpoints, where to enable RazorPages you currently need a separate class:

public class ExampleRouteRegistration : IRouteRegistration
{
    public void RegisterRoutes(IEndpointRouteBuilder routeBuilder)
    {
        routeBuilder.MapRazorPages();
    }
}

public class Startup
{
    public IConfiguration Configuration { get; }

    public Startup(IConfiguration configuration)
    {
        Configuration = configuration;
    }

    public void ConfigureServices(IServiceCollection services)
    {
        services
            .AddRazorPages()
            .AddCofoundry(Configuration);
    }

    public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
    {
        app.UseCofoundry();
    }
}

It would be nice in a simple scenario to be abel to do something like this, which runs at a default point in the startup pipeline:

public class Startup
{
    public IConfiguration Configuration { get; }

    public Startup(IConfiguration configuration)
    {
        Configuration = configuration;
    }

    public void ConfigureServices(IServiceCollection services)
    {
        services
            .AddRazorPages()
            .AddCofoundry(Configuration);
    }

    public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
    {
        app.UseCofoundry(c =>
        {
            c.AppBuilder.MapRazorPages();
        });
    }
}
@HeyJoel HeyJoel added this to the 0.9 milestone Jun 1, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant