Skip to content

add staticFS supports #1865

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
1 task done
zxysilent opened this issue Apr 30, 2021 · 1 comment
Closed
1 task done

add staticFS supports #1865

zxysilent opened this issue Apr 30, 2021 · 1 comment

Comments

@zxysilent
Copy link

add staticFS

Checklist

  • [x ] Dependencies installed
  • [x ] No typos
  • Searched existing issues and docs

Expected behaviour

Actual behaviour

Steps to reproduce

Working code to debug

package main

import (
	"embed"
	 "net/http"
	"github.com/labstack/echo/v4"
	"github.com/labstack/echo/v4/middleware"
)

//go:embed static
var static embed.FS
func main() {
	engine := echo.New()
	engine.Static("/static", "static")
	// use embed
	engine.StaticFS("/staticfs",http.FS(static))
	// or
	engine.StaticFS("/staticfs",static)
	engine.Start("8080")
}

Version/commit

@aldas
Copy link
Contributor

aldas commented May 8, 2021

Static middleware has now support for Filesystem. This was added with #1797 and will be release in v4.3.

	e.Use(middleware.StaticWithConfig(middleware.StaticConfig{
		Root:       ".",
		Filesystem: http.FS(os.DirFS("../_fixture")),
	}))

@aldas aldas closed this as completed May 8, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants