aboutsummaryrefslogtreecommitdiff
path: root/server.go
diff options
context:
space:
mode:
authorSimon Ser <contact@emersion.fr>2019-12-09 16:02:12 +0100
committerSimon Ser <contact@emersion.fr>2019-12-09 16:05:40 +0100
commit4f74722c14d18e78e172825961d7a65d25b41d3f (patch)
tree7ffe867986e26e4b5f4a27cb061030e2337efa96 /server.go
parenta176409933129eccdcf06ef131c76aee497b53aa (diff)
downloadalps-4f74722c14d18e78e172825961d7a65d25b41d3f.tar.gz
alps-4f74722c14d18e78e172825961d7a65d25b41d3f.zip
Add basic support for plugins
Diffstat (limited to 'server.go')
-rw-r--r--server.go8
1 files changed, 8 insertions, 0 deletions
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 {