🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
DemoInstallSign in
Socket

gopkg.in/jeevatkm/middleware.v0

Package Overview
Dependencies
Alerts
File Explorer
Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

gopkg.in/jeevatkm/middleware.v0

v0.1.0
Go
Version published
Created
Source

Middleware Build Status GoDoc GoCover

A collection of HTTP middleware/Handler function for use with Go's net/http package. Compatible with Goji, Gorilla, Negroni & net/http (amongst many others).

  • Minify HTTP middleware using tdewolff/minify
  • will be adding few...

Start using it

  • Installation
go get github.com/jeevatkm/middleware
                   OR
go get gopkg.in/jeevatkm/middleware.v0
  • Import it in your code
import "github.com/jeevatkm/middleware"
                   OR
import "gopkg.in/jeevatkm/middleware.v0"

Examples

Refer examples

Vanilla net/http

func main() {
	homeHandler := http.HandlerFunc(home)

	// Adding Minify middleware
	// Note: If you use any Gzip middleware, add Minify middleware after that
	http.Handle("/", middleware.Minify(homeHandler))

	log.Println("Starting server at localhost:8000")
	http.ListenAndServe(":8000", nil)
}

Goji web framework

func main() {
	// Adding Minify middleware
	// Note: If you use any Gzip middleware, add Minify middleware after that
	goji.Use(middleware.Minify)

	goji.Get("/", gojiHome)
	goji.Serve()
}

Gorilla Mux

func main() {
	r := mux.NewRouter()
	r.HandleFunc("/", gorillaHome)

	// Adding Minify middleware
	// Note: If you use any Gzip middleware, add Minify middleware after that
	http.Handle("/", middleware.Minify(r))

	log.Println("Starting server at localhost:8000")
	http.ListenAndServe(":8000", nil)
}

Negroni web middleware

func main() {
	mux := http.NewServeMux()
	mux.HandleFunc("/", negroniHome)

	n := negroni.Classic()

	// Adding Minify middleware
	n.UseHandler(middleware.Minify(mux))

	n.Run(":8000")
}

License

Middleware released under MIT License

FAQs

Package last updated on 19 Aug 2015

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts