Skip to content

Latest commit

 

History

15 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Nancy.Gzip Build status License

Adds gzip compression to your Nancy web application.

Installation

PM> Install-Package Nancy.Gzip

General Usage

Enable gzip compression in your bootstrapper.

public class Bootstrapper : DefaultNancyBootstrapper
{
    protected override void ApplicationStartup(TinyIoCContainer container, IPipelines pipelines)
    {
        // Enable Compression with Default Settings
        pipelines.EnableGzipCompression();

        base.ApplicationStartup(container, pipelines);
    }
}

Settings

There are only two setings in which you can configure

Minimum Bytes

The default minimum size (Content-Length) of output before it will be compressed is 4096. If the size is below this amount, it will not be compressed.

Mime Types

There are default mime types which specify which mime types are valid for compression. You can add your own content types to this list.

The defaults are:

  • text/plain
  • text/html
  • text/xml
  • text/css
  • application/json
  • application/x-javascript
  • application/atom+xml

Settings Example

public class Bootstrapper : DefaultNancyBootstrapper
{
    protected override void ApplicationStartup(TinyIoCContainer container, IPipelines pipelines)
    {
        // Enable Compression with Settings
        var settings = new GzipCompressionSettings();
        settings.MinimumBytes = 1024;
        settings.MimeTypes.Add("application/vnd.myexample");
        pipelines.EnableGzipCompression(settings);

        base.ApplicationStartup(container, pipelines);
    }
}

Icon

Icons made by Freepik from www.flaticon.com is licensed by CC 3.0 BY

About

Easily adds gzip compression to your Nancy web application.

Resources

Stars

24 stars

Watchers

5 watching

Forks

Releases

Packages

Used by

Contributors

Languages