Skip to content

Commit

Permalink
Merge pull request #703 from luraproject/fix_plugin_load
Browse files Browse the repository at this point in the history
Do not abort the loading of handler plugins when one of them fails to…
  • Loading branch information
taik0 authored Jan 11, 2024
2 parents 0660048 + 75907fb commit 1196698
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions transport/http/server/plugin/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,23 +56,23 @@ func New(logger logging.Logger, next RunServer) RunServer {
for _, name := range fifo {
rawHf, ok := r.Get(name)
if !ok {
logger.Debug(logPrefix, "No plugin resgistered as", name)
return next(ctx, cfg, handler)
logger.Error(logPrefix, "No plugin resgistered as", name)
continue
}

hf, ok := rawHf.(func(context.Context, map[string]interface{}, http.Handler) (http.Handler, error))
if !ok {
logger.Warning(logPrefix, "Wrong plugin handler type:", name)
return next(ctx, cfg, handler)
logger.Error(logPrefix, "Wrong plugin handler type:", name)
continue
}

handlerWrapper, err := hf(ctx, extra, handler)
if err != nil {
logger.Warning(logPrefix, "Error getting the plugin handler:", err.Error())
logger.Error(logPrefix, "Error getting the plugin handler:", err.Error())
continue
}

logger.Debug(logPrefix, "Injecting plugin", name)
logger.Info(logPrefix, "Injecting plugin", name)
handler = handlerWrapper
}
return next(ctx, cfg, handler)
Expand Down

0 comments on commit 1196698

Please sign in to comment.