mirror of
https://github.com/zitadel/zitadel.git
synced 2024-12-14 11:58:02 +00:00
e4843d7692
* fix(middleware): init translation messages
* revert change
* refactor: split loop in separate function
* add imports to ensure init of fs
(cherry picked from commit 9bcfa12be2
)
54 lines
1.1 KiB
Go
54 lines
1.1 KiB
Go
package i18n
|
|
|
|
import (
|
|
"net/http"
|
|
|
|
"github.com/rakyll/statik/fs"
|
|
"github.com/zitadel/logging"
|
|
|
|
// ensure fs is setup
|
|
_ "github.com/zitadel/zitadel/internal/api/ui/login/statik"
|
|
_ "github.com/zitadel/zitadel/internal/notification/statik"
|
|
_ "github.com/zitadel/zitadel/internal/statik"
|
|
)
|
|
|
|
var zitadelFS, loginFS, notificationFS http.FileSystem
|
|
|
|
type Namespace string
|
|
|
|
const (
|
|
ZITADEL Namespace = "zitadel"
|
|
LOGIN Namespace = "login"
|
|
NOTIFICATION Namespace = "notification"
|
|
)
|
|
|
|
func LoadFilesystem(ns Namespace) http.FileSystem {
|
|
var err error
|
|
defer func() {
|
|
if err != nil {
|
|
logging.WithFields("namespace", ns).OnError(err).Panic("unable to get namespace")
|
|
}
|
|
}()
|
|
switch ns {
|
|
case ZITADEL:
|
|
if zitadelFS != nil {
|
|
return zitadelFS
|
|
}
|
|
zitadelFS, err = fs.NewWithNamespace(string(ns))
|
|
return zitadelFS
|
|
case LOGIN:
|
|
if loginFS != nil {
|
|
return loginFS
|
|
}
|
|
loginFS, err = fs.NewWithNamespace(string(ns))
|
|
return loginFS
|
|
case NOTIFICATION:
|
|
if notificationFS != nil {
|
|
return notificationFS
|
|
}
|
|
notificationFS, err = fs.NewWithNamespace(string(ns))
|
|
return notificationFS
|
|
}
|
|
return nil
|
|
}
|