uon-nuget / UoN.AspNetCore.VersionMiddleware

UoN shared code ASP.NET Core version middleware
MIT License
1 stars 1 forks source link

[!NOTE] This repository is archived. The source for this package has moved into a monorepo here:

:octocat: https://github.com/uon-nuget/UoN.VersionInformation

UoN.AspNetCore.VersionMiddleware

License Build Status NuGet

What is it?

This is middleware for ASP.Net Core designed to report on version information related to your project.

We use it at UoN so that we can check the version of a web app wherever it's deployed, without having to display it publicly to users who don't care. This is useful for ensuring testers know which builds they're working with and therefore what fixes to test.

What are its features?

It exposes the version output of UoN.VersionInformation as JSON data at an http endpoint.

Middleware Extension Methods

It provides three IApplicationBuilder Extension methods for you to use in Startup.Configure():

Dependencies

The library targets netstandard2.0 and depends upon ASP.NET Core 2.0 and UoN.VersionInformation.

If you can use ASP.NET Core 2, you can use this library.

Example usage

Startup.cs

public class Startup
{
  ...

  // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
  public void Configure(IApplicationBuilder app, IHostingEnvironment env)
  {
    if (env.IsDevelopment())
    {
      app.UseDeveloperExceptionPage();
    }
    else
    {
        app.UseExceptionHandler("/Home/Error");
    }

    app.UseVersion(); //adds `/version` to the pipeline, so if that endpoint is requested, the pipeline will short circuit here

    app.UseStaticFiles();

    app.UseMvc(routes =>
    {
        routes.MapRoute(
            name: "default",
            template: "{controller=Home}/{action=Index}/{id?}");
    });
  }
}

Building from source

We recommend building with the dotnet cli, but since the package targets netstandard2.0 and depends only on ASP.Net Core 2.0, you should be able to build it in any tooling that supports those requirements.

Contributing

Contributions are unlikely to be needed often as this is a library with a very specific purpose.

If there are issues open, please feel free to make pull requests for them, and they will be reviewed.