embed.go 435 B

1234567891011121314151617181920212223242526272829
  1. //go:build !unembed
  2. package middleware
  3. import (
  4. "io/fs"
  5. "net/http"
  6. "path"
  7. "github.com/0xJacky/Nginx-UI/app"
  8. "github.com/gin-contrib/static"
  9. "github.com/uozi-tech/cosy/logger"
  10. )
  11. func MustFs(dir string) (serverFileSystem static.ServeFileSystem) {
  12. sub, err := fs.Sub(app.DistFS, path.Join("dist", dir))
  13. if err != nil {
  14. logger.Error(err)
  15. return
  16. }
  17. serverFileSystem = ServerFileSystemType{
  18. http.FS(sub),
  19. }
  20. return
  21. }