1
0
mirror of https://github.com/kataras/iris.git synced 2025-12-18 10:27:06 +00:00

New iris.DirOptions.PushTargetsRegexp

rel to: https://github.com/kataras/iris/issues/1562#issuecomment-659702891


Former-commit-id: 778cf9146b730d424040ea9e259ce6500f53b563
This commit is contained in:
Gerasimos (Makis) Maropoulos
2020-07-18 06:10:16 +03:00
parent dab03102f3
commit 552f990358
4 changed files with 116 additions and 12 deletions

View File

@@ -1,6 +1,8 @@
package main
import (
"regexp"
"github.com/kataras/iris/v12"
)
@@ -13,13 +15,20 @@ var opts = iris.DirOptions{
//
// Note: Requires running server under TLS,
// that's why we use `iris.TLS` below.
PushTargets: map[string][]string{
"/": { // Relative path without route prefix.
"favicon.ico",
"js/main.js",
"css/main.css",
// ^ Relative to the index, if need absolute ones start with a slash ('/').
},
// PushTargets: map[string][]string{
// "/": { // Relative path without prefix.
// "favicon.ico",
// "js/main.js",
// "css/main.css",
// // ^ Relative to the index, if need absolute ones start with a slash ('/').
// },
// },
// OR use regexp:
PushTargetsRegexp: map[string]*regexp.Regexp{
// Match all js, css and ico files
// from all files (recursively).
// "/": regexp.MustCompile("((.*).js|(.*).css|(.*).ico)$"),
"/": iris.MatchCommonAssets,
},
Compress: true,
ShowList: true,