GithubHelp home page GithubHelp logo

hansospina / kitura-compression Goto Github PK

View Code? Open in Web Editor NEW

This project forked from kitura/kitura-compression

0.0 2.0 0.0 200 KB

Kitura compression middleware

License: Apache License 2.0

Swift 100.00%

kitura-compression's Introduction

Kitura-Compression

Kitura compression middleware

Build Status - Master Mac OS X Linux Apache 2

Summary

Kitura compression middleware for compressing body data sent back to the client. Supports deflate and gzip compression methods. Uses zlib.

Table of Contents

Swift version

The latest version of Kitura-Compression requires Swift 3.0. You can download this version of the Swift binaries by following this link. Compatibility with other Swift versions is not guaranteed.

API

In order to use compression middleware, create an instance of Compression, and connect it to the desired path:

import KituraCompression

router.all(middleware: Compression())

You can configure Compression with optional arguments:

    public init (threshold: Int = 1024, chunkSize: Int = 16384, compressionLevel: CompressionLevel = CompressionLevel.defaultCompression, compressionStrategy: CompressionStrategy = CompressionStrategy.defaultStrategy, memoryLevel: Int32 = 8)

Where:

  • threshold is the byte threshold for the response body size before compression is considered for the response, defaults to 1024.

  • chunkSize is the size of internal output slab buffer in bytes, defaults to 16384

  • compressionLevel is the level of zlib compression to apply. The supported values are:
    .noCompression, .bestSpeed, .bestCompression, .defaultCompression

  • compressionStrategy is used to tune the compression algorithm. Here are its possible values:
    .defaultStrategy, .filtered, .huffmanOnly, .rle, .fixed

  • memoryLevel specifies how much memory should be allocated for the internal compression state. The default value is 8.

For more information on compression parameters, see zlib manual.

License

This library is licensed under Apache 2.0. Full license text is available in LICENSE.

kitura-compression's People

Contributors

shmuelk avatar irar2 avatar bdhernand avatar ianpartridge avatar vadimeisenbergibm avatar carlbrown avatar na-gupta avatar hansospina avatar quanvo87 avatar youming-lin avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.