1
0
mirror of https://github.com/labstack/echo.git synced 2024-12-24 20:14:31 +02:00

Replace the redirection with a direct call to url package

This commit is contained in:
Alexandre Stein 2018-04-03 17:04:28 +02:00 committed by Vishal Rana
parent af1bfd5397
commit 37f1a470ef
2 changed files with 7 additions and 6 deletions

10
echo.go
View File

@ -447,7 +447,7 @@ func (e *Echo) Static(prefix, root string) *Route {
func static(i i, prefix, root string) *Route { func static(i i, prefix, root string) *Route {
h := func(c Context) error { h := func(c Context) error {
p, err := PathUnescape(c.Param("*")) p, err := url.PathUnescape(c.Param("*"))
if err != nil { if err != nil {
return err return err
} }
@ -749,10 +749,10 @@ func handlerName(h HandlerFunc) string {
return t.String() return t.String()
} }
// PathUnescape is wraps `url.PathUnescape` // // PathUnescape is wraps `url.PathUnescape`
func PathUnescape(s string) (string, error) { // func PathUnescape(s string) (string, error) {
return url.PathUnescape(s) // return url.PathUnescape(s)
} // }
// tcpKeepAliveListener sets TCP keep-alive timeouts on accepted // tcpKeepAliveListener sets TCP keep-alive timeouts on accepted
// connections. It's used by ListenAndServe and ListenAndServeTLS so // connections. It's used by ListenAndServe and ListenAndServeTLS so

View File

@ -3,6 +3,7 @@ package middleware
import ( import (
"fmt" "fmt"
"net/http" "net/http"
"net/url"
"os" "os"
"path" "path"
"path/filepath" "path/filepath"
@ -76,7 +77,7 @@ func StaticWithConfig(config StaticConfig) echo.MiddlewareFunc {
if strings.HasSuffix(c.Path(), "*") { // When serving from a group, e.g. `/static*`. if strings.HasSuffix(c.Path(), "*") { // When serving from a group, e.g. `/static*`.
p = c.Param("*") p = c.Param("*")
} }
p, err = echo.PathUnescape(p) p, err = url.PathUnescape(p)
if err != nil { if err != nil {
return return
} }