1
0
mirror of https://github.com/muety/wakapi.git synced 2023-08-10 21:12:56 +03:00

fix: neutered file system

docs: add filter params to api docs
This commit is contained in:
Ferdinand Mütsch
2021-12-26 19:29:17 +01:00
parent cbcdd938eb
commit 6f9015d3d8
7 changed files with 316 additions and 9 deletions

19
main.go
View File

@@ -247,18 +247,19 @@ func main() {
// https://github.com/golang/go/issues/43431
embeddedStatic, _ := fs.Sub(staticFiles, "static")
static := conf.ChooseFS("static", embeddedStatic)
fileServer := gzipped.FileServer(fsutils.NewExistsHttpFS(
fsutils.NewExistsFS(
fsutils.NeuteredFileSystem{
FS: static,
}).WithCache(!config.IsDev()),
assetsFileServer := gzipped.FileServer(fsutils.NewExistsHttpFS(
fsutils.NewExistsFS(static).WithCache(!config.IsDev()),
))
staticFileServer := http.FileServer(http.FS(
fsutils.NeuteredFileSystem{FS: static},
))
router.PathPrefix("/contribute.json").Handler(fileServer)
router.PathPrefix("/assets").Handler(fileServer)
router.PathPrefix("/swagger-ui").Handler(fileServer)
router.PathPrefix("/contribute.json").Handler(staticFileServer)
router.PathPrefix("/assets").Handler(assetsFileServer)
router.PathPrefix("/swagger-ui").Handler(staticFileServer)
router.PathPrefix("/docs").Handler(
middlewares.NewFileTypeFilterMiddleware([]string{".go"})(fileServer),
middlewares.NewFileTypeFilterMiddleware([]string{".go"})(staticFileServer),
)
// Miscellaneous