app/plugin: add product middleware and enable products register their routers (#20374)

Этот коммит содержится в:
Ibrahim Serdar Acikgoz
2022-06-07 09:12:15 +03:00
коммит произвёл GitHub
родитель 2580722426
Коммит c1c084a596
4 изменённых файлов: 37 добавлений и 1 удалений

Просмотреть файл

@@ -21,6 +21,14 @@ import (
)
func (ch *Channels) ServePluginRequest(w http.ResponseWriter, r *http.Request) {
params := mux.Vars(r)
if handler, ok := ch.routerSvc.getHandler(params["plugin_id"]); ok {
ch.servePluginRequest(w, r, func(*plugin.Context, http.ResponseWriter, *http.Request) {
handler.ServeHTTP(w, r)
})
return
}
pluginsEnvironment := ch.GetPluginsEnvironment()
if pluginsEnvironment == nil {
err := model.NewAppError("ServePluginRequest", "app.plugin.disabled.app_error", nil, "Enable plugins to serve plugin requests", http.StatusNotImplemented)
@@ -31,7 +39,6 @@ func (ch *Channels) ServePluginRequest(w http.ResponseWriter, r *http.Request) {
return
}
params := mux.Vars(r)
hooks, err := pluginsEnvironment.HooksForPlugin(params["plugin_id"])
if err != nil {
mlog.Debug("Access to route for non-existent plugin",