From 020e27fe459b0ed66a48b46cb2878520ed4a517b Mon Sep 17 00:00:00 2001 From: Simon Ser Date: Tue, 17 Dec 2019 15:14:15 +0100 Subject: Add Context to Plugin.Inject This allows to access the request metadata and the session from injectors. --- plugin_go.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'plugin_go.go') diff --git a/plugin_go.go b/plugin_go.go index 407363c..9974c17 100644 --- a/plugin_go.go +++ b/plugin_go.go @@ -40,14 +40,14 @@ func (p *goPlugin) SetRoutes(group *echo.Group) { group.Static("/plugins/"+p.p.Name+"/assets", pluginDir+"/"+p.p.Name+"/public/assets") } -func (p *goPlugin) Inject(name string, data RenderData) error { +func (p *goPlugin) Inject(ctx *Context, name string, data RenderData) error { if f, ok := p.p.injectFuncs["*"]; ok { - if err := f(data); err != nil { + if err := f(ctx, data); err != nil { return err } } if f, ok := p.p.injectFuncs[name]; ok { - return f(data) + return f(ctx, data) } return nil } @@ -114,7 +114,7 @@ func (p *GoPlugin) TemplateFuncs(funcs template.FuncMap) { } // InjectFunc is a function that injects data prior to rendering a template. -type InjectFunc func(data RenderData) error +type InjectFunc func(ctx *Context, data RenderData) error // Inject registers a function to execute prior to rendering a template. The // special name "*" matches any template. -- cgit v1.2.3-59-g8ed1b