From 6f8bb9e9da7d2b7597acbbdeea5f0df58fac1c5f Mon Sep 17 00:00:00 2001 From: Fabricio Date: Sun, 10 Mar 2019 13:05:05 -0300 Subject: [PATCH] exit on plugin failure --- main.go | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/main.go b/main.go index 05308fb..9de22c9 100644 --- a/main.go +++ b/main.go @@ -12,6 +12,7 @@ import ( "net/http/httptest" "net/http/httputil" "net/url" + "os" "plugin" "strings" @@ -142,17 +143,17 @@ func NewPlugin(next http.HandlerFunc) http.HandlerFunc { p, err := plugin.Open(file.Name()) if err != nil { fmt.Println("error: could not open plugin:", err) - continue + os.Exit(1) } fn, err := p.Lookup("Handler") if err != nil { fmt.Println("error: could not find plugin Handler function:", err) - continue + os.Exit(1) } pluginHandler, ok := fn.(func(http.HandlerFunc) http.HandlerFunc) if !ok { fmt.Println("error: plugin Handler function should be 'func(http.HandlerFunc) http.HandlerFunc'") - continue + os.Exit(1) } next = pluginHandler(next) }