Quellcode durchsuchen

middleware docs

tags/v0.9.0
jimzhan vor 9 Jahren
Ursprung
Commit
ba010b76d6
4 geänderte Dateien mit 4 neuen und 3 gelöschten Zeilen
  1. +1
    -0
      middleware/compress.go
  2. +1
    -0
      middleware/header.go
  3. +1
    -0
      middleware/logger.go
  4. +1
    -3
      middleware/xsrf.go

+ 1
- 0
middleware/compress.go Datei anzeigen

@@ -98,6 +98,7 @@ func (self *compressor) Write(data []byte) (size int, err error) {
return self.ResponseWriter.Write(data)
}

// GZIP/Deflate compression supports.
func Compress(next http.Handler) http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
if r.Header.Get("Sec-WebSocket-Key") != "" || r.Method == "HEAD" {

+ 1
- 0
middleware/header.go Datei anzeigen

@@ -2,6 +2,7 @@ package middleware

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 {
return func(next http.Handler) http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {

+ 1
- 0
middleware/logger.go Datei anzeigen

@@ -7,6 +7,7 @@ import (
"github.com/Sirupsen/logrus"
)

// Logger renders the simple HTTP accesses logs for the upcoming http.Handler.
func Logger(next http.Handler) http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
start := time.Now()

+ 1
- 3
middleware/xsrf.go Datei anzeigen

@@ -133,9 +133,7 @@ func (self *xsrf) generate() {
self.token = token
}

// ---------------------------------------------------------------------------
// XSRF Middleware Supports
// ---------------------------------------------------------------------------
// XSRF serves as Cross-Site Request Forgery protection middleware.
func XSRF(next http.Handler) http.Handler {
fn := func(w http.ResponseWriter, r *http.Request) {
x := new(xsrf)

Laden…
Abbrechen
Speichern