1
0
mirror of https://github.com/kataras/iris.git synced 2026-01-09 13:05:56 +00:00
This commit is contained in:
Gerasimos (Makis) Maropoulos
2021-01-09 05:41:20 +02:00
parent 72c2dafd2e
commit 8aedf6bc32
36 changed files with 99 additions and 130 deletions

View File

@@ -41,7 +41,7 @@ func ProxyHandler(target *url.URL) *httputil.ReverseProxy {
if netutil.IsLoopbackHost(target.Host) {
transport := &http.Transport{
TLSClientConfig: &tls.Config{InsecureSkipVerify: true},
TLSClientConfig: &tls.Config{InsecureSkipVerify: true}, // lint:ignore
}
p.Transport = transport
}

View File

@@ -56,9 +56,9 @@ func (m myTestTask) OnServe(host TaskHost) {
if rans == exitAfterXRestarts {
m.logger.Println("exit")
ctx, cancel := context.WithTimeout(context.TODO(), 5*time.Second)
defer cancel()
_ = host.Supervisor.Shutdown(ctx) // total shutdown
host.Supervisor.RestoreFlow() // free to exit (if shutdown)
cancel()
return
}

View File

@@ -363,9 +363,6 @@ func (e Entry) UintDefault(def uint) (uint, error) {
if err != nil {
return def, err
}
if val > uint64(maxValue) {
return def, e.notFound(reflect.Uint)
}
return uint(val), nil
case uint:
return vv, nil
@@ -412,9 +409,6 @@ func (e Entry) Uint8Default(def uint8) (uint8, error) {
if err != nil {
return def, err
}
if val > math.MaxUint8 {
return def, e.notFound(reflect.Uint8)
}
return uint8(val), nil
case uint:
if vv > math.MaxUint8 {
@@ -462,9 +456,6 @@ func (e Entry) Uint16Default(def uint16) (uint16, error) {
if err != nil {
return def, err
}
if val > math.MaxUint16 {
return def, e.notFound(reflect.Uint16)
}
return uint16(val), nil
case uint:
if vv > math.MaxUint16 {
@@ -509,9 +500,6 @@ func (e Entry) Uint32Default(def uint32) (uint32, error) {
if err != nil {
return def, err
}
if val > math.MaxUint32 {
return def, e.notFound(reflect.Uint32)
}
return uint32(val), nil
case uint:
if vv > math.MaxUint32 {
@@ -555,9 +543,6 @@ func (e Entry) Uint64Default(def uint64) (uint64, error) {
if err != nil {
return def, err
}
if val > math.MaxUint64 {
return def, e.notFound(reflect.Uint64)
}
return uint64(val), nil
case uint8:
return uint64(vv), nil
@@ -590,9 +575,6 @@ func (e Entry) Float32Default(key string, def float32) (float32, error) {
if err != nil {
return def, err
}
if val > math.MaxFloat32 {
return def, e.notFound(reflect.Float32)
}
return float32(val), nil
case float32:
return vv, nil

View File

@@ -442,9 +442,9 @@ func StripPrefix(prefix string, h context.Handler) context.Handler {
func toWebPath(systemPath string) string {
// winos slash to slash
webpath := strings.Replace(systemPath, "\\", "/", -1)
webpath := strings.ReplaceAll(systemPath, "\\", "/")
// double slashes to single
webpath = strings.Replace(webpath, "//", "/", -1)
webpath = strings.ReplaceAll(webpath, "//", "/")
return webpath
}
@@ -1013,7 +1013,7 @@ func cacheFiles(ctx stdContext.Context, fs http.FileSystem, names []string, comp
case <-ctx.Done():
return ctx.Err()
default:
break
break // lint:ignore
}
if alg == "brotli" {
@@ -1218,7 +1218,7 @@ var _ http.File = (*dir)(nil)
// returns unorderded map of directories both reclusive and flat.
func findDirs(fs http.FileSystem, names []string) (map[string]*dir, error) {
dirs := make(map[string]*dir, 0)
dirs := make(map[string]*dir)
for _, name := range names {
f, err := fs.Open(name)

View File

@@ -19,7 +19,7 @@ func Param(name string) string {
// WildcardParam receives a parameter name prefixed with the WildcardParamStart symbol.
func WildcardParam(name string) string {
if len(name) == 0 {
if name == "" {
return ""
}
return prefix(name, WildcardParamStart)

View File

@@ -378,7 +378,7 @@ func formatPath(path string) string {
var formattedParts []string
parts := strings.Split(path, "/")
for _, part := range parts {
if len(part) == 0 {
if part == "" {
continue
}
if part[0] == startRune || part[0] == wildcardStartRune {
@@ -566,7 +566,7 @@ func (r *Route) Trace(w io.Writer, stoppedIndex int) {
if stoppedIndex != -1 && stoppedIndex <= len(r.Handlers) {
if i <= stoppedIndex {
pio.WriteRich(w, " ✓", pio.Green)
} else {
// } else {
// pio.WriteRich(w, " ✕", pio.Red, pio.Underline)
}
}

View File

@@ -136,10 +136,7 @@ func (router *Router) buildMainHandlerWithFilters(routerFilters map[Party]*Filte
}
if leftSlashLen == rightSlashLen {
if len(left.Path) > len(right.Path) {
return true
}
return false
return len(left.Path) > len(right.Path)
}
return len(left.Path) > len(right.Path)