mirror of
https://github.com/labstack/echo.git
synced 2025-07-13 01:30:31 +02:00
Don't need http.Dir in Context#File'
Signed-off-by: Vishal Rana <vr@labstack.com>
This commit is contained in:
@ -7,6 +7,7 @@ import (
|
|||||||
"mime"
|
"mime"
|
||||||
"mime/multipart"
|
"mime/multipart"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
"os"
|
||||||
"path"
|
"path"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"time"
|
"time"
|
||||||
@ -365,9 +366,7 @@ func (c *context) XMLBlob(code int, b []byte) (err error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (c *context) File(file string) error {
|
func (c *context) File(file string) error {
|
||||||
root, file := filepath.Split(file)
|
f, err := os.Open(file)
|
||||||
fs := http.Dir(root)
|
|
||||||
f, err := fs.Open(file)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return ErrNotFound
|
return ErrNotFound
|
||||||
}
|
}
|
||||||
@ -376,7 +375,7 @@ func (c *context) File(file string) error {
|
|||||||
fi, _ := f.Stat()
|
fi, _ := f.Stat()
|
||||||
if fi.IsDir() {
|
if fi.IsDir() {
|
||||||
file = path.Join(file, "index.html")
|
file = path.Join(file, "index.html")
|
||||||
f, err = fs.Open(file)
|
f, err = os.Open(file)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return ErrNotFound
|
return ErrNotFound
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user