mirror of
https://github.com/zeromicro/go-zero.git
synced 2026-05-11 00:40:00 +08:00
feat: support embed file system to serve files in rest (#4253)
This commit is contained in:
@@ -5,8 +5,9 @@ import (
|
||||
"strings"
|
||||
)
|
||||
|
||||
func Middleware(path, dir string) func(http.HandlerFunc) http.HandlerFunc {
|
||||
fileServer := http.FileServer(http.Dir(dir))
|
||||
// Middleware returns a middleware that serves files from the given file system.
|
||||
func Middleware(path string, fs http.FileSystem) func(http.HandlerFunc) http.HandlerFunc {
|
||||
fileServer := http.FileServer(fs)
|
||||
pathWithTrailSlash := ensureTrailingSlash(path)
|
||||
pathWithoutTrailSlash := ensureNoTrailingSlash(path)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user