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

Using filepath instead of path

Signed-off-by: Vishal Rana <vr@labstack.com>
This commit is contained in:
Vishal Rana 2015-09-17 12:12:01 -07:00
parent d09485810d
commit 1d4ee61baa

View File

@ -8,7 +8,7 @@ import (
"io" "io"
"log" "log"
"net/http" "net/http"
spath "path" "path/filepath"
"reflect" "reflect"
"runtime" "runtime"
"strings" "strings"
@ -382,7 +382,7 @@ func (e *Echo) ServeDir(path, dir string) {
// ServeFile serves a file. // ServeFile serves a file.
func (e *Echo) ServeFile(path, file string) { func (e *Echo) ServeFile(path, file string) {
e.Get(path, func(c *Context) error { e.Get(path, func(c *Context) error {
dir, file := spath.Split(file) dir, file := filepath.Split(file)
return serveFile(dir, file, c) return serveFile(dir, file, c)
}) })
} }
@ -396,7 +396,7 @@ func serveFile(dir, file string, c *Context) error {
fi, _ := f.Stat() fi, _ := f.Stat()
if fi.IsDir() { if fi.IsDir() {
file = spath.Join(file, indexFile) file = filepath.Join(file, indexFile)
f, err = fs.Open(file) f, err = fs.Open(file)
if err != nil { if err != nil {
return NewHTTPError(http.StatusForbidden) return NewHTTPError(http.StatusForbidden)