1
0
mirror of https://github.com/kataras/iris.git synced 2026-01-17 08:55:57 +00:00

use the new protobuf package and other minor stuff

Former-commit-id: 29bf71e8a73d34b27c6f5fe3f12c4ea1cc2b84b2
This commit is contained in:
Gerasimos (Makis) Maropoulos
2020-06-21 17:15:28 +03:00
parent d55bb34766
commit 29d98ac281
22 changed files with 59 additions and 105 deletions

View File

@@ -30,7 +30,6 @@ import (
"github.com/Shopify/goreferrer"
"github.com/fatih/structs"
"github.com/golang/protobuf/proto"
"github.com/iris-contrib/blackfriday"
"github.com/iris-contrib/schema"
jsoniter "github.com/json-iterator/go"
@@ -39,6 +38,7 @@ import (
"github.com/vmihailenco/msgpack/v5"
"golang.org/x/net/publicsuffix"
"golang.org/x/time/rate"
"google.golang.org/protobuf/proto"
"gopkg.in/yaml.v3"
)
@@ -1879,8 +1879,6 @@ func (ctx *context) FullRequestURI() string {
return ctx.AbsoluteURI(ctx.Path())
}
const xForwardedForHeaderKey = "X-Forwarded-For"
// RemoteAddr tries to parse and return the real client's request IP.
//
// Based on allowed headers names that can be modified from Configuration.RemoteAddrHeaders.
@@ -2396,13 +2394,11 @@ func (ctx *context) URLParamBool(name string) (bool, error) {
// URLParams returns a map of GET query parameters separated by comma if more than one
// it returns an empty map if nothing found.
func (ctx *context) URLParams() map[string]string {
values := map[string]string{}
q := ctx.request.URL.Query()
if q != nil {
for k, v := range q {
values[k] = strings.Join(v, ",")
}
values := make(map[string]string, len(q))
for k, v := range q {
values[k] = strings.Join(v, ",")
}
return values
@@ -4815,7 +4811,7 @@ func (rs *rateReadSeeker) Read(buf []byte) (int, error) {
if n <= 0 {
return n, err
}
rs.limiter.WaitN(rs.ctx, n)
err = rs.limiter.WaitN(rs.ctx, n)
return n, err
}

View File

@@ -182,7 +182,12 @@ func (w *ResponseRecorder) Clone() ResponseWriter {
wc.headers = w.headers
wc.chunks = w.chunks[0:]
if resW, ok := w.ResponseWriter.(*responseWriter); ok {
wc.ResponseWriter = &(*resW) // clone it
wc.ResponseWriter = &responseWriter{
ResponseWriter: resW.ResponseWriter,
statusCode: resW.statusCode,
written: resW.written,
beforeFlush: resW.beforeFlush,
} // clone it
} else { // else just copy, may pointer, developer can change its behavior
wc.ResponseWriter = w.ResponseWriter
}