|
@@ -44,15 +44,16 @@ type RoutesInfo []RouteInfo
|
|
|
// Create an instance of Engine, by using New() or Default()
|
|
// Create an instance of Engine, by using New() or Default()
|
|
|
type Engine struct {
|
|
type Engine struct {
|
|
|
RouterGroup
|
|
RouterGroup
|
|
|
- delims render.Delims
|
|
|
|
|
- HTMLRender render.HTMLRender
|
|
|
|
|
- FuncMap template.FuncMap
|
|
|
|
|
- allNoRoute HandlersChain
|
|
|
|
|
- allNoMethod HandlersChain
|
|
|
|
|
- noRoute HandlersChain
|
|
|
|
|
- noMethod HandlersChain
|
|
|
|
|
- pool sync.Pool
|
|
|
|
|
- trees methodTrees
|
|
|
|
|
|
|
+ delims render.Delims
|
|
|
|
|
+ secureJsonPrefix string
|
|
|
|
|
+ HTMLRender render.HTMLRender
|
|
|
|
|
+ FuncMap template.FuncMap
|
|
|
|
|
+ allNoRoute HandlersChain
|
|
|
|
|
+ allNoMethod HandlersChain
|
|
|
|
|
+ noRoute HandlersChain
|
|
|
|
|
+ noMethod HandlersChain
|
|
|
|
|
+ pool sync.Pool
|
|
|
|
|
+ trees methodTrees
|
|
|
|
|
|
|
|
// Enables automatic redirection if the current route can't be matched but a
|
|
// Enables automatic redirection if the current route can't be matched but a
|
|
|
// handler for the path with (without) the trailing slash exists.
|
|
// handler for the path with (without) the trailing slash exists.
|
|
@@ -121,6 +122,7 @@ func New() *Engine {
|
|
|
UnescapePathValues: true,
|
|
UnescapePathValues: true,
|
|
|
trees: make(methodTrees, 0, 9),
|
|
trees: make(methodTrees, 0, 9),
|
|
|
delims: render.Delims{"{{", "}}"},
|
|
delims: render.Delims{"{{", "}}"},
|
|
|
|
|
+ secureJsonPrefix: "while(1);",
|
|
|
}
|
|
}
|
|
|
engine.RouterGroup.engine = engine
|
|
engine.RouterGroup.engine = engine
|
|
|
engine.pool.New = func() interface{} {
|
|
engine.pool.New = func() interface{} {
|
|
@@ -145,6 +147,11 @@ func (engine *Engine) Delims(left, right string) *Engine {
|
|
|
return engine
|
|
return engine
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+func (engine *Engine) SecureJsonPrefix(prefix string) *Engine {
|
|
|
|
|
+ engine.secureJsonPrefix = prefix
|
|
|
|
|
+ return engine
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
func (engine *Engine) LoadHTMLGlob(pattern string) {
|
|
func (engine *Engine) LoadHTMLGlob(pattern string) {
|
|
|
if IsDebugging() {
|
|
if IsDebugging() {
|
|
|
debugPrintLoadTemplate(template.Must(template.New("").Delims(engine.delims.Left, engine.delims.Right).Funcs(engine.FuncMap).ParseGlob(pattern)))
|
|
debugPrintLoadTemplate(template.Must(template.New("").Delims(engine.delims.Left, engine.delims.Right).Funcs(engine.FuncMap).ParseGlob(pattern)))
|