-
-
Notifications
You must be signed in to change notification settings - Fork 2.5k
/
main.go
44 lines (38 loc) · 1.16 KB
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
package main
import (
"github.com/kataras/iris/v12"
)
// Follow these steps first:
// $ go install github.com/go-bindata/go-bindata/v3/go-bindata@latest
// $ go-bindata -prefix "assets" -fs ./assets/...
// $ go run .
// "physical" files are not used, you can delete the "assets" folder and run the example.
//
// See `file-server/embedding-gzipped-files-into-app-bindata` and
// 'file-server/embedding-files-into-app` examples as well.
func newApp() *iris.Application {
app := iris.New()
app.Logger().SetLevel("debug")
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", iris.Dir("./assets"), iris.DirOptions{
IndexName: "index.html",
Cache: iris.DirCacheOptions{
Enable: true,
Encodings: []string{"gzip"},
CompressIgnore: iris.MatchImagesAssets,
CompressMinSize: 30 * iris.B,
},
})
*/
return app
}
func main() {
app := newApp()
// http://localhost:8080/static/css/main.css
// http://localhost:8080/static/js/main.js
// http://localhost:8080/static/favicon.ico
app.Listen(":8080")
}