Skip to content

An ASP.NET Core middlware for injecting the GNU Terry Pratchett header into all HTTP responses

License

Notifications You must be signed in to change notification settings

GaProgMan/ClacksMiddleware

Repository files navigation

ClacksMiddleware

ClacksMiddleware is an ASP.NET Core middlware class which will inject the GNU Terry Pratchett HTTP header into all responses.

Build Status

Build status

Licence

License: MIT

Support This Project

If you have found this project helpful, either as a library that you use or as a learning tool, please consider buying me a coffee:

Buy Me A Coffee

Code of Conduct

ClacksMiddleware has a Code of Conduct which all contributors, maintainers and forkers must adhere to. When contributing, maintaining, forking or in any other way changing the code presented in this repository, all users must agree to this Code of Conduct.

See Code of Conduct.md for details.

Usage

TL;DR

See: The code in ClacksMiddlwareExample directory for a worked example

Long Form

Install the latest version of the NuGet package into an ASP.NET Core application.

Add a reference to the ClacksMiddleware namespace in the Startup class:

using ClacksMiddleware;

Add the middleware to the ASP.NET Core middleware pipeline (the middleware class is called GnuTerryPratchett. Example:

public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
{
  loggerFactory.AddConsole(Configuration.GetSection("Logging"));
  loggerFactory.AddDebug();

  // Add our middlware before any others. Otherwise it may
  // not affect the response for the incoming request
  app.GnuTerryPratchett();

  app.UseMvc();
}

Request a page within the application, and check the response headers:

secure headers shown in network tab

About

An ASP.NET Core middlware for injecting the GNU Terry Pratchett header into all HTTP responses

Topics

Resources

License

Code of conduct

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published