mirror of
https://github.com/zitadel/zitadel.git
synced 2025-08-12 10:49:25 +00:00
chore: move the go code into a subfolder
This commit is contained in:
53
apps/api/internal/i18n/fs.go
Normal file
53
apps/api/internal/i18n/fs.go
Normal file
@@ -0,0 +1,53 @@
|
||||
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
|
||||
}
|
Reference in New Issue
Block a user