return self.ResponseWriter.Write(data) | return self.ResponseWriter.Write(data) | ||||
} | } | ||||
// GZIP/Deflate compression supports. | |||||
func Compress(next http.Handler) http.Handler { | func Compress(next http.Handler) http.Handler { | ||||
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { | return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { | ||||
if r.Header.Get("Sec-WebSocket-Key") != "" || r.Method == "HEAD" { | if r.Header.Get("Sec-WebSocket-Key") != "" || r.Method == "HEAD" { |
import "net/http" | import "net/http" | ||||
// Header adds the given response headers to the upcoming `http.ResponseWriter`. | |||||
func Header(values map[string]string) func(http.Handler) http.Handler { | func Header(values map[string]string) func(http.Handler) http.Handler { | ||||
return func(next http.Handler) http.Handler { | return func(next http.Handler) http.Handler { | ||||
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { | return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { |
"github.com/Sirupsen/logrus" | "github.com/Sirupsen/logrus" | ||||
) | ) | ||||
// Logger renders the simple HTTP accesses logs for the upcoming http.Handler. | |||||
func Logger(next http.Handler) http.Handler { | func Logger(next http.Handler) http.Handler { | ||||
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { | return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { | ||||
start := time.Now() | start := time.Now() |
self.token = token | self.token = token | ||||
} | } | ||||
// --------------------------------------------------------------------------- | |||||
// XSRF Middleware Supports | |||||
// --------------------------------------------------------------------------- | |||||
// XSRF serves as Cross-Site Request Forgery protection middleware. | |||||
func XSRF(next http.Handler) http.Handler { | func XSRF(next http.Handler) http.Handler { | ||||
fn := func(w http.ResponseWriter, r *http.Request) { | fn := func(w http.ResponseWriter, r *http.Request) { | ||||
x := new(xsrf) | x := new(xsrf) |