mirror of
https://github.com/labstack/echo.git
synced 2024-12-24 20:14:31 +02:00
Fixed default options for static
Signed-off-by: Vishal Rana <vr@labstack.com>
This commit is contained in:
parent
b97a2c5ad6
commit
4f6fd9725d
@ -20,14 +20,17 @@ type (
|
||||
func Static(root string, options ...*StaticOptions) echo.MiddlewareFunc {
|
||||
return func(next echo.Handler) echo.Handler {
|
||||
// Default options
|
||||
opts := &StaticOptions{Index: "index.html"}
|
||||
opts := new(StaticOptions)
|
||||
if len(options) > 0 {
|
||||
opts = options[0]
|
||||
}
|
||||
if opts.Index == "" {
|
||||
opts.Index = "index.html"
|
||||
}
|
||||
|
||||
return echo.HandlerFunc(func(c echo.Context) error {
|
||||
fs := http.Dir(root)
|
||||
file := c.Request().URI()
|
||||
file := path.Clean(c.Request().URL().Path())
|
||||
f, err := fs.Open(file)
|
||||
if err != nil {
|
||||
return next.Handle(c)
|
||||
|
Loading…
Reference in New Issue
Block a user