mirror of
https://github.com/kataras/iris.git
synced 2026-01-10 05:25:58 +00:00
replace ioutil with io package and other minor improvements
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@@ -166,10 +166,12 @@ func (u *SimpleUser) GetField(key string) (interface{}, error) {
|
||||
|
||||
// UserMap can be used to convert a common map[string]interface{} to a User.
|
||||
// Usage:
|
||||
// user := map[string]interface{}{
|
||||
// "username": "kataras",
|
||||
// "age" : 27,
|
||||
// }
|
||||
//
|
||||
// user := map[string]interface{}{
|
||||
// "username": "kataras",
|
||||
// "age" : 27,
|
||||
// }
|
||||
//
|
||||
// ctx.SetUser(user)
|
||||
// OR
|
||||
// user := UserStruct{....}
|
||||
|
||||
@@ -275,7 +275,6 @@ type Filter func(*Context) bool
|
||||
// Handlers here should act like middleware, they should contain `ctx.Next` to proceed
|
||||
// to the next handler of the chain. Those "handlers" are registered to the per-request context.
|
||||
//
|
||||
//
|
||||
// It checks the "filter" and if passed then
|
||||
// it, correctly, executes the "handlers".
|
||||
//
|
||||
|
||||
@@ -131,11 +131,12 @@ func (r *RequestParams) GetIntUnslashed(key string) (int, bool) {
|
||||
// Key is the specific type, which should be unique.
|
||||
// The value is a function which accepts the parameter index
|
||||
// and it should return the value as the parameter type evaluator expects it.
|
||||
// i.e [reflect.TypeOf("string")] = func(paramIndex int) interface{} {
|
||||
// return func(ctx *Context) <T> {
|
||||
// return ctx.Params().GetEntryAt(paramIndex).ValueRaw.(<T>)
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// i.e [reflect.TypeOf("string")] = func(paramIndex int) interface{} {
|
||||
// return func(ctx *Context) <T> {
|
||||
// return ctx.Params().GetEntryAt(paramIndex).ValueRaw.(<T>)
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// Read https://github.com/kataras/iris/tree/master/_examples/routing/macros for more details.
|
||||
// Checks for total available request parameters length
|
||||
@@ -261,7 +262,9 @@ var ParamResolvers = map[reflect.Type]func(paramIndex int) interface{}{
|
||||
// and the parameter's index based on the registered path.
|
||||
// Usage: nameResolver := ParamResolverByKindAndKey(reflect.TypeOf(""), 0)
|
||||
// Inside a Handler: nameResolver.Call(ctx)[0]
|
||||
// it will return the reflect.Value Of the exact type of the parameter(based on the path parameters and macros).
|
||||
//
|
||||
// it will return the reflect.Value Of the exact type of the parameter(based on the path parameters and macros).
|
||||
//
|
||||
// It is only useful for dynamic binding of the parameter, it is used on "hero" package and it should be modified
|
||||
// only when Macros are modified in such way that the default selections for the available go std types are not enough.
|
||||
//
|
||||
|
||||
@@ -4,7 +4,7 @@ import (
|
||||
"bytes"
|
||||
"errors"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"io"
|
||||
"net/http"
|
||||
"net/textproto"
|
||||
"strconv"
|
||||
@@ -32,7 +32,7 @@ func releaseResponseRecorder(w *ResponseRecorder) {
|
||||
// A ResponseRecorder is used mostly for testing
|
||||
// in order to record and modify, if necessary, the body and status code and headers.
|
||||
//
|
||||
// See `context.Recorder`` method too.
|
||||
// See `context.Recorder“ method too.
|
||||
type ResponseRecorder struct {
|
||||
ResponseWriter
|
||||
|
||||
@@ -366,7 +366,7 @@ func (w *ResponseRecorder) Result() *http.Response { // a modified copy of net/h
|
||||
}
|
||||
res.Status = fmt.Sprintf("%03d %s", res.StatusCode, http.StatusText(res.StatusCode))
|
||||
if w.chunks != nil {
|
||||
res.Body = ioutil.NopCloser(bytes.NewReader(w.chunks))
|
||||
res.Body = io.NopCloser(bytes.NewReader(w.chunks))
|
||||
} else {
|
||||
res.Body = http.NoBody
|
||||
}
|
||||
|
||||
@@ -111,7 +111,6 @@ func StatusText(code int) string {
|
||||
// Read more at `iris/Configuration#DisableAutoFireStatusCode` and
|
||||
// `iris/core/router/Party#OnAnyErrorCode` for relative information.
|
||||
//
|
||||
//
|
||||
// Modify this variable when your Iris server or/and client
|
||||
// not follows the RFC: https://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html
|
||||
var StatusCodeNotSuccessful = func(statusCode int) bool { return statusCode >= 400 }
|
||||
|
||||
Reference in New Issue
Block a user