1
0
mirror of https://github.com/kataras/iris.git synced 2025-12-21 20:07:04 +00:00

(#1554) Add support for all common compressions (write and read)

- Remove the context.Context interface and export the *context, the iris.Context now points to the pointer\nSupport compression and rate limiting in the FileServer\nBit of code organisation


Former-commit-id: ad1c61bf968059510c6be9e7f2cceec7da70ba17
This commit is contained in:
Gerasimos (Makis) Maropoulos
2020-07-10 23:21:09 +03:00
parent 645da2b2ef
commit 0f113dfcda
112 changed files with 2119 additions and 3390 deletions

View File

@@ -3,8 +3,6 @@ package context
import (
"bufio"
"errors"
"fmt"
"io"
"net"
"net/http"
"sync"
@@ -15,8 +13,8 @@ import (
//
// Note: Only this ResponseWriter is an interface in order to be able
// for developers to change the response writer of the Context via `context.ResetResponseWriter`.
// The rest of the response writers implementations (ResponseRecorder & GzipResponseWriter) are coupled to the internal
// ResponseWriter implementation(*responseWriter).
// The rest of the response writers implementations (ResponseRecorder & CompressResponseWriter)
// are coupled to the internal ResponseWriter implementation(*responseWriter).
//
// A ResponseWriter may not be used after the Handler
// has returned.
@@ -45,16 +43,6 @@ type ResponseWriter interface {
// IsHijacked reports whether this response writer's connection is hijacked.
IsHijacked() bool
// Writef formats according to a format specifier and writes to the response.
//
// Returns the number of bytes written and any write error encountered.
Writef(format string, a ...interface{}) (n int, err error)
// WriteString writes a simple string to the response.
//
// Returns the number of bytes written and any write error encountered.
WriteString(s string) (n int, err error)
// StatusCode returns the status code header value.
StatusCode() int
@@ -279,23 +267,6 @@ func (w *responseWriter) Write(contents []byte) (int, error) {
return n, err
}
// Writef formats according to a format specifier and writes to the response.
//
// Returns the number of bytes written and any write error encountered.
func (w *responseWriter) Writef(format string, a ...interface{}) (n int, err error) {
return fmt.Fprintf(w, format, a...)
}
// WriteString writes a simple string to the response.
//
// Returns the number of bytes written and any write error encountered.
func (w *responseWriter) WriteString(s string) (int, error) {
w.tryWriteHeader()
n, err := io.WriteString(w.ResponseWriter, s)
w.written += n
return n, err
}
// StatusCode returns the status code header value
func (w *responseWriter) StatusCode() int {
return w.statusCode