From ac4c675a197db8b4f9bc9535fb61a03a64ef15bd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jes=C3=BAs=20Espino?= Date: Fri, 12 Jun 2020 22:26:35 +0200 Subject: [PATCH] Fixing plugin routes (#14805) Automatic Merge --- app/app.go | 6 ------ app/server_app_adapters.go | 7 +++++++ 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/app/app.go b/app/app.go index db2d1308c7..87c4c4d8f2 100644 --- a/app/app.go +++ b/app/app.go @@ -86,12 +86,6 @@ func (a *App) InitServer() { } } - pluginsRoute := a.srv.Router.PathPrefix("/plugins/{plugin_id:[A-Za-z0-9\\_\\-\\.]+}").Subrouter() - pluginsRoute.HandleFunc("", a.ServePluginRequest) - pluginsRoute.HandleFunc("/public/{public_file:.*}", a.ServePluginPublicRequest) - pluginsRoute.HandleFunc("/{anything:.*}", a.ServePluginRequest) - a.srv.Router.NotFoundHandler = http.HandlerFunc(a.Handle404) - // Scheduler must be started before cluster. a.initJobs() diff --git a/app/server_app_adapters.go b/app/server_app_adapters.go index 803482cd0f..049716e840 100644 --- a/app/server_app_adapters.go +++ b/app/server_app_adapters.go @@ -139,6 +139,13 @@ func (s *Server) RunOldAppInitialization() error { } s.Router = s.RootRouter.PathPrefix(subpath).Subrouter() + // FakeApp: remove this when we have the ServePluginRequest and ServePluginPublicRequest migrated in the server + fakeApp := New(ServerConnector(s)) + pluginsRoute := s.Router.PathPrefix("/plugins/{plugin_id:[A-Za-z0-9\\_\\-\\.]+}").Subrouter() + pluginsRoute.HandleFunc("", fakeApp.ServePluginRequest) + pluginsRoute.HandleFunc("/public/{public_file:.*}", fakeApp.ServePluginPublicRequest) + pluginsRoute.HandleFunc("/{anything:.*}", fakeApp.ServePluginRequest) + // If configured with a subpath, redirect 404s at the root back into the subpath. if subpath != "/" { s.RootRouter.NotFoundHandler = http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {