From 4f74722c14d18e78e172825961d7a65d25b41d3f Mon Sep 17 00:00:00 2001 From: Simon Ser Date: Mon, 9 Dec 2019 16:02:12 +0100 Subject: Add basic support for plugins --- server.go | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'server.go') diff --git a/server.go b/server.go index d8aeca7..0845628 100644 --- a/server.go +++ b/server.go @@ -28,6 +28,8 @@ type Server struct { tls bool insecure bool } + + plugins []Plugin } func (s *Server) parseIMAPURL(imapURL string) error { @@ -131,6 +133,11 @@ func New(e *echo.Echo, options *Options) error { return fmt.Errorf("failed to load templates: %v", err) } + s.plugins, err = loadAllLuaPlugins(e.Logger) + if err != nil { + return fmt.Errorf("failed to load plugins: %v", err) + } + e.HTTPErrorHandler = func(err error, c echo.Context) { code := http.StatusInternalServerError if he, ok := err.(*echo.HTTPError); ok { @@ -145,6 +152,7 @@ func New(e *echo.Echo, options *Options) error { e.Use(func(next echo.HandlerFunc) echo.HandlerFunc { return func(ectx echo.Context) error { ctx := &context{Context: ectx, server: s} + ctx.Set("context", ctx) cookie, err := ctx.Cookie(cookieName) if err == http.ErrNoCookie { -- cgit v1.2.3-59-g8ed1b