mirror of
https://github.com/kataras/iris.git
synced 2025-12-24 05:17:03 +00:00
directly support embed.FS and fs.FS on view engines
This commit is contained in:
11
view/fs.go
11
view/fs.go
@@ -7,6 +7,8 @@ import (
|
||||
"path"
|
||||
"path/filepath"
|
||||
"sort"
|
||||
|
||||
"github.com/kataras/iris/v12/context"
|
||||
)
|
||||
|
||||
// walk recursively in "fs" descends "root" path, calling "walkFn".
|
||||
@@ -90,17 +92,14 @@ func getFS(fsOrDir interface{}) (fs http.FileSystem) {
|
||||
return noOpFS{}
|
||||
}
|
||||
|
||||
switch v := fsOrDir.(type) {
|
||||
case string:
|
||||
if v, ok := fsOrDir.(string); ok {
|
||||
if v == "" {
|
||||
fs = noOpFS{}
|
||||
} else {
|
||||
fs = httpDirWrapper{http.Dir(v)}
|
||||
}
|
||||
case http.FileSystem:
|
||||
fs = v
|
||||
default:
|
||||
panic(fmt.Errorf(`unexpected "fsOrDir" argument type of %T (string or http.FileSystem)`, v))
|
||||
} else {
|
||||
fs = context.ResolveFS(fsOrDir)
|
||||
}
|
||||
|
||||
return
|
||||
|
||||
Reference in New Issue
Block a user