Skip to content
This repository was archived by the owner on Feb 16, 2023. It is now read-only.
Fernando Escolar edited this page May 6, 2021 · 2 revisions

It is an object that creates a web application host with a default configuration. It allows you write a fast single file API.

When you write:

new ApiApp()
  .ConfigureServices(services => /* Configure your services */)
  .Configure( (app, env) => /* Configure your application */)
  .Run();

Is the same than:

CreateHostBuilder(args).Build().Run();

static IHostBuilder CreateHostBuilder(string[] args) =>
	Host.CreateDefaultBuilder(args)
		.ConfigureWebHostDefaults(webBuilder =>
		{
			webBuilder.UseStartup<Startup>();
		});

class Startup
{
  public void ConfigureServices(IServiceCollection services)
  {
    /* Configure your services */
    services.AddRouteRecords();
  }

  public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
  {
    if (env.IsDevelopment())
    {
      app.UseDeveloperExceptionPage();
    }

     /* Configure your application */

    app.UseRouting();
    app.UseEndpoints(endpoints => endpoints.MapRouteRecords());
  }
}

Clone this wiki locally