1
0

resources_embedded.go 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. // Copyright (C) 2019-2023 Nicola Murino
  2. //
  3. // This program is free software: you can redistribute it and/or modify
  4. // it under the terms of the GNU Affero General Public License as published
  5. // by the Free Software Foundation, version 3.
  6. //
  7. // This program is distributed in the hope that it will be useful,
  8. // but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  10. // GNU Affero General Public License for more details.
  11. //
  12. // You should have received a copy of the GNU Affero General Public License
  13. // along with this program. If not, see <https://www.gnu.org/licenses/>.
  14. //go:build bundle
  15. // +build bundle
  16. package httpd
  17. import (
  18. "net/http"
  19. "github.com/go-chi/chi/v5"
  20. "github.com/drakkan/sftpgo/v2/internal/bundle"
  21. )
  22. func serveStaticDir(router chi.Router, path, fsDirPath string, disableDirectoryIndex bool) {
  23. switch path {
  24. case webStaticFilesPath:
  25. fileServer(router, path, bundle.GetStaticFs(), disableDirectoryIndex)
  26. case webOpenAPIPath:
  27. fileServer(router, path, bundle.GetOpenAPIFs(), disableDirectoryIndex)
  28. default:
  29. fileServer(router, path, http.Dir(fsDirPath), disableDirectoryIndex)
  30. }
  31. }