2021-05-03 14:54:28 +02:00
|
|
|
//nolint:gochecknoglobals,golint,stylecheck
|
2021-05-03 14:51:53 +02:00
|
|
|
package web
|
|
|
|
|
2021-05-14 09:48:45 +02:00
|
|
|
import (
|
|
|
|
"embed"
|
|
|
|
"io/fs"
|
|
|
|
"net/http"
|
|
|
|
|
|
|
|
"github.com/rs/zerolog/log"
|
|
|
|
)
|
2021-05-03 14:51:53 +02:00
|
|
|
|
|
|
|
//go:embed files
|
2021-05-14 09:48:45 +02:00
|
|
|
var files embed.FS
|
|
|
|
|
|
|
|
var Files = sub(files, "files")
|
2021-05-03 14:51:53 +02:00
|
|
|
|
|
|
|
//go:embed templates
|
|
|
|
var Templates embed.FS
|
2021-05-14 09:48:45 +02:00
|
|
|
|
|
|
|
//go:embed swagger-ui
|
|
|
|
var swaggerUI embed.FS
|
|
|
|
|
|
|
|
var SwaggerUI = sub(swaggerUI, "swagger-ui")
|
|
|
|
|
|
|
|
func sub(f embed.FS, dir string) http.FileSystem {
|
|
|
|
fsys, err := fs.Sub(f, dir)
|
|
|
|
if err != nil {
|
|
|
|
log.Error().Err(err).Str("dir", dir).Msg("could not sub into dir")
|
|
|
|
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
return http.FS(fsys)
|
|
|
|
}
|