1
0
mirror of https://github.com/kataras/iris.git synced 2025-12-18 02:17:05 +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

@@ -27,7 +27,7 @@ func FromStd(handler interface{}) context.Handler {
//
// handlerFunc.ServeHTTP(w,r)
//
return func(ctx context.Context) {
return func(ctx *context.Context) {
h.ServeHTTP(ctx.ResponseWriter(), ctx.Request())
}
}
@@ -51,7 +51,7 @@ func FromStd(handler interface{}) context.Handler {
// No valid handler passed
//
panic(fmt.Errorf(`
Passed argument is not a func(context.Context) neither one of these types:
Passed argument is not a func(iris.Context) neither one of these types:
- http.Handler
- func(w http.ResponseWriter, r *http.Request)
- func(w http.ResponseWriter, r *http.Request, next http.HandlerFunc)
@@ -64,7 +64,7 @@ func FromStd(handler interface{}) context.Handler {
// FromStdWithNext receives a standar handler - middleware form - and returns a
// compatible context.Handler wrapper.
func FromStdWithNext(h func(w http.ResponseWriter, r *http.Request, next http.HandlerFunc)) context.Handler {
return func(ctx context.Context) {
return func(ctx *context.Context) {
next := func(w http.ResponseWriter, r *http.Request) {
ctx.ResetRequest(r)
ctx.Next()

View File

@@ -54,7 +54,7 @@ func TestFromStdWithNext(t *testing.T) {
}
h := handlerconv.FromStdWithNext(stdWNext)
next := func(ctx context.Context) {
next := func(ctx *context.Context) {
ctx.WriteString(ctx.Request().Context().Value(contextKey("key")).(string))
}