mirror of
https://github.com/kataras/iris.git
synced 2025-12-18 10:27:06 +00:00
New DirOptions.Cache field for in-memory caching and pre-compression for the fastest possible static file server
Read HISTORY.md it contains a breaking change, second parameter of HandleDir should be iris.Dir(...) instead of just a string relative to: https://github.com/kataras/iris/issues/1556#issuecomment-661057446 Former-commit-id: 14b48a06fb3b99287dff543932be2937a64233b9
This commit is contained in:
File diff suppressed because one or more lines are too long
@@ -5,8 +5,8 @@ import (
|
||||
)
|
||||
|
||||
// Follow these steps first:
|
||||
// $ go get -u github.com/go-bindata/go-bindata/...
|
||||
// $ go-bindata ./assets/...
|
||||
// $ go get -u github.com/go-bindata/go-bindata/v3/go-bindata
|
||||
// $ go-bindata -prefix "assets" -fs ./assets/...
|
||||
// $ go run .
|
||||
// "physical" files are not used, you can delete the "assets" folder and run the example.
|
||||
//
|
||||
@@ -15,13 +15,21 @@ func newApp() *iris.Application {
|
||||
app := iris.New()
|
||||
app.Logger().SetLevel("debug")
|
||||
|
||||
app.HandleDir("/static", "./assets", iris.DirOptions{
|
||||
Asset: Asset,
|
||||
AssetInfo: AssetInfo,
|
||||
AssetNames: AssetNames,
|
||||
ShowList: true,
|
||||
})
|
||||
app.HandleDir("/static", AssetFile())
|
||||
|
||||
/*
|
||||
Or if you need to cache them inside the memory (requires the assets folder
|
||||
to be located near the executable program):
|
||||
app.HandleDir("/static", http.Dir("./assets"), iris.DirOptions{
|
||||
IndexName: "index.html",
|
||||
Cache: iris.DirCacheOptions{
|
||||
Enable: true,
|
||||
Encodings: []string{"gzip"},
|
||||
CompressIgnore: iris.MatchImagesAssets,
|
||||
CompressMinSize: 30 * iris.B,
|
||||
},
|
||||
})
|
||||
*/
|
||||
return app
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user