Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/ZewoGraveyard/GZIP
Swift GZIP data compression for macOS and Linux
https://github.com/ZewoGraveyard/GZIP
Last synced: 3 months ago
JSON representation
Swift GZIP data compression for macOS and Linux
- Host: GitHub
- URL: https://github.com/ZewoGraveyard/GZIP
- Owner: ZewoGraveyard
- License: mit
- Created: 2016-05-22T19:10:25.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2016-12-12T18:31:40.000Z (almost 8 years ago)
- Last Synced: 2024-05-18T22:51:27.541Z (6 months ago)
- Language: Swift
- Homepage:
- Size: 74.2 KB
- Stars: 22
- Watchers: 4
- Forks: 5
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- TheList - Zewo gzip - gzip data compression from Swift, OS X & Linux ready. (Server Side Utilities / Compression)
README
# gzip
[![Build Status](https://travis-ci.org/Zewo/gzip.svg?branch=master)](https://travis-ci.org/Zewo/gzip)
![Platforms](https://img.shields.io/badge/platforms-Linux%20%7C%20OS%20X-blue.svg)
![Package Managers](https://img.shields.io/badge/package%20managers-SwiftPM-yellow.svg)[![Blog](https://img.shields.io/badge/blog-honzadvorsky.com-green.svg)](http://honzadvorsky.com)
[![Twitter Czechboy0](https://img.shields.io/badge/twitter-czechboy0-green.svg)](http://twitter.com/czechboy0)> gzip data compression from Swift, OS X & Linux ready
# Usage
Works on `Data` or anything [`Gzippable`](https://github.com/czechboy0/gzip/blob/master/Sources/gzip/gzip%2BData.swift#L42-46)```swift
let myData = ... //Data
let myGzipCompressedData = try myData.gzipCompressed() //Data
...
let myGzipUncompressedData = try myGzipCompressedData.gzipUncompressed() //Data
... //PROFIT!
```Middleware to suport gzipped content in `HTTPClient`.
```swift
let request = ... //Request
let response = try client.request(request, middleware: [GzipMiddleware()])
```
Please note, that `GzipMiddleware` should be placed at the end of a chain:
```swift
let response = try client.request(request, middleware: [ContentNegotiationMiddleware(mediaTypes: [.json], mode: .client), GzipMiddleware()])
```# Details
As this library uses a SwiftPM-compatible source of [zlib](https://github.com/Zewo/zlib), you don't need to install anything manually before using it. Even though both OS X and Linux have a preinstalled version of `zlib`, unfortunately each has a different version, making its potential use inconsistent. In our case everything is compiled from source, so you can be sure to get the same results everywhere. :100:
# Installation
## Swift Package Manager
```swift
.Package(url: "https://github.com/Zewo/gzip.git", majorVersion: 0, minor: 8)
```:gift_heart: Contributing
------------
Please create an issue with a description of your problem or open a pull request with a fix.:+1: Thanks
------
This project was initially inspired by [NSData+GZIP](https://github.com/1024jp/NSData-GZIP), thank you!:v: License
-------
MIT:alien: Author
------
Honza Dvorsky - http://honzadvorsky.com, [@czechboy0](http://twitter.com/czechboy0)