1
0
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:
Gerasimos (Makis) Maropoulos
2022-09-21 23:26:12 +03:00
parent 5bc0796548
commit 95a8110f1e
12 changed files with 162 additions and 17 deletions

View File

@@ -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