• Stars
    star
    60
  • Rank 485,869 (Top 10 %)
  • Language
    Go
  • License
    Other
  • Created almost 10 years ago
  • Updated over 3 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Gzip middleware for Negroni

gzip

Gzip middleware for Negroni.

Mostly a copy of the Martini gzip module with small changes to make it function under Negroni. Support for setting the compression level has also been added and tests have been written. Test coverage is 100% according to go cover.

Usage

package main

import (
    "fmt"
    "net/http"

    "github.com/urfave/negroni"
    "github.com/phyber/negroni-gzip/gzip"
)

func main() {
    mux := http.NewServeMux()
    mux.HandleFunc("/", func(w http.ResponseWriter, req *http.Request) {
    	  fmt.Fprintf(w, "Welcome to the home page!")
    })

    n := negroni.Classic()
    n.Use(gzip.Gzip(gzip.DefaultCompression))
    n.UseHandler(mux)
    n.Run(":3000")
}

Make sure to include the Gzip middleware above any other middleware that alter the response body.

Tips

As noted above, any middleware that alters response body will need to be below the Gzip middleware. If you wish to gzip static files served by the default negroni Static middleware you will need to include negroni.Static() after gzip.Gzip().

    n := negroni.New()
    n.Use(negroni.NewRecovery())
    n.Use(negroni.NewLogger())
    n.Use(gzip.Gzip(gzip.DefaultCompression))
    n.Use(negroni.NewStatic(http.Dir("public")))

Warning

Compressing TLS traffic may leak the page contents to an attacker if the page contains user input. See the BREACH article on Wikipedia for more information.

Authors

And many others. Check the commit log for a complete list.

More Repositories

1

TiBUdecrypter

Decrypt backup files from Titanium Backup on the command line.
Python
53
star
2

jail_exporter

A Prometheus exporter for FreeBSD jail metrics
Rust
29
star
3

ciso

Compress and decompress ISO/CSO files
Python
14
star
4

nzbchecker

Checks how complete the NZB set is on a given NNTP server
Python
9
star
5

zsh.d

ZSH environment
Shell
5
star
6

TweetDelete

Delete old tweets from your Twitter timeline.
Python
5
star
7

irssi-scripts

My irssi scripts.
Perl
5
star
8

mutt-mailboxes

Mailbox sorter for mutt sidebar
Python
5
star
9

Fizzle

Show item durability and quality in the character frame.
Lua
4
star
10

tweetdelete-rs

Deletes Tweets older than N days
Rust
3
star
11

XPBarNone

XP bar for World of Warcraft
Lua
3
star
12

jailconf-rs

A FreeBSD jail.conf parser written in Rust
Rust
3
star
13

avsg

Axiom Verge Save Game Viewer
Rust
3
star
14

mpyc

Web-based MPD client using Flask and associated gizmos.
JavaScript
2
star
15

docker-mdns

Tool for publishing mDNS names via Avahi based on Docker labels
Rust
2
star
16

rmsshkey

Removes host entries from SSH known_hosts along with all associated addresses.
Go
2
star
17

awesome-config

Awesome WM configuration
Lua
2
star
18

ProjectEuler

Solutions for ProjectEuler
C
1
star
19

Cosplay

Adds a button to undress the model in the Dressing room.
Lua
1
star
20

BlizzTorrentEx

Extract torrents from Blizzard downloaders
C
1
star
21

flask_mpd

MPD extension for Flask.
Python
1
star
22

weechat-scripts

Various scripts for Weechat. Some original, some patched.
Python
1
star
23

snippetsMate

Snippets for snipMate
1
star
24

pinboard-rs

Pinboard CLI client written in Rust
Rust
1
star
25

Snippets

Snippets of code
Lua
1
star
26

upsidedown-rs

Small Rust program that flips text upside down
Rust
1
star
27

cyd

cyd: Convert Your Data
Rust
1
star
28

Broker_RestFu

Keeps track of time played and rested XP across your characters.
Lua
1
star
29

ciso-rs

Compress and decompress ISO and CSO files
Rust
1
star
30

Broker_BagFu

Keeps track of space left in your bags.
Lua
1
star