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:
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user