diff options
author | Simon Ser <contact@emersion.fr> | 2019-12-09 16:02:12 +0100 |
---|---|---|
committer | Simon Ser <contact@emersion.fr> | 2019-12-09 16:05:40 +0100 |
commit | 4f74722c14d18e78e172825961d7a65d25b41d3f (patch) | |
tree | 7ffe867986e26e4b5f4a27cb061030e2337efa96 /server.go | |
parent | a176409933129eccdcf06ef131c76aee497b53aa (diff) | |
download | alps-4f74722c14d18e78e172825961d7a65d25b41d3f.tar.gz alps-4f74722c14d18e78e172825961d7a65d25b41d3f.zip |
Add basic support for plugins
Diffstat (limited to 'server.go')
-rw-r--r-- | server.go | 8 |
1 files changed, 8 insertions, 0 deletions
@@ -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 { |