forest_admin_rails 1.12.0 → 1.12.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: '099b5f8e72f047e94d152def7e081f05321c7bf0b1aaa75f0484c917acd7fc61'
|
|
4
|
+
data.tar.gz: 0af28ac77c06cbed7cb5212c244232a1f3a3e42aa64a49f02c34281f821d61a9
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: c1c0422ec8739e19267569261e0afe16e1cca5f1673cbf65ceab6142000c9df32b96235745fad440b16e67d4f9751a1b1785ed6b15fde86f404f4e62dd09c973
|
|
7
|
+
data.tar.gz: ab902ad4d0e18a6f5dd332f9e358f7d018208f7c931984f86b7ebeafe0b3717c23058f2a723adfbe32ccfc599df483d3bb67ab54535e17b1d0720489f9eed043
|
|
@@ -7,8 +7,8 @@ module ForestAdminRails
|
|
|
7
7
|
skip_forgery_protection
|
|
8
8
|
|
|
9
9
|
def index
|
|
10
|
-
if ForestAdminAgent::Http::Router.
|
|
11
|
-
route = ForestAdminAgent::Http::Router.
|
|
10
|
+
if ForestAdminAgent::Http::Router.cached_routes.key? params['route_alias']
|
|
11
|
+
route = ForestAdminAgent::Http::Router.cached_routes[params['route_alias']]
|
|
12
12
|
|
|
13
13
|
begin
|
|
14
14
|
forest_response route[:closure].call({ params: params.to_unsafe_h, headers: request.headers.to_h })
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
if defined?(ForestAdminAgent::Http::Router)
|
|
2
|
+
cache_disabled = ForestAdminAgent::Http::Router.cache_disabled?
|
|
3
|
+
|
|
4
|
+
if cache_disabled
|
|
5
|
+
Rails.logger.warn('[ForestAdmin] Route caching is DISABLED - this will impact performance')
|
|
6
|
+
Rails.logger.warn('[ForestAdmin] To enable caching, remove disable_route_cache: true from configuration')
|
|
7
|
+
else
|
|
8
|
+
Rails.application.config.after_initialize do
|
|
9
|
+
start_time = Time.now
|
|
10
|
+
routes = ForestAdminAgent::Http::Router.cached_routes
|
|
11
|
+
elapsed = ((Time.now - start_time) * 1000).round(2)
|
|
12
|
+
|
|
13
|
+
Rails.logger.info(
|
|
14
|
+
"[ForestAdmin] Successfully pre-cached #{routes.size} routes in #{elapsed}ms"
|
|
15
|
+
)
|
|
16
|
+
rescue StandardError => e
|
|
17
|
+
Rails.logger.error(
|
|
18
|
+
"[ForestAdmin] CRITICAL: Failed to pre-cache routes: #{e.class} - #{e.message}"
|
|
19
|
+
)
|
|
20
|
+
Rails.logger.error(e.backtrace.first(10).join("\n"))
|
|
21
|
+
|
|
22
|
+
raise e if Rails.env.production?
|
|
23
|
+
|
|
24
|
+
Rails.logger.warn(
|
|
25
|
+
'[ForestAdmin] Routes will be computed on first request (performance degradation)'
|
|
26
|
+
)
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
end
|
data/config/routes.rb
CHANGED
|
@@ -1,15 +1,20 @@
|
|
|
1
1
|
ForestAdminRails::Engine.routes.draw do
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
end
|
|
2
|
+
scope '/forest' do
|
|
3
|
+
# Use cached_routes to avoid recomputing routes during Rails route initialization
|
|
4
|
+
ForestAdminAgent::Http::Router.cached_routes.each do |name, agent_route|
|
|
5
|
+
match agent_route[:uri],
|
|
6
|
+
defaults: { format: agent_route[:format] },
|
|
7
|
+
to: 'forest#index',
|
|
8
|
+
via: agent_route[:method],
|
|
9
|
+
as: name,
|
|
10
|
+
route_alias: name,
|
|
11
|
+
constraints: { id: /[a-zA-Z0-9\.]*+/ }
|
|
13
12
|
end
|
|
13
|
+
rescue StandardError => e
|
|
14
|
+
if defined?(Rails) && Rails.logger
|
|
15
|
+
Rails.logger.error("[ForestAdmin] CRITICAL: Failed to initialize routes: #{e.class} - #{e.message}")
|
|
16
|
+
Rails.logger.error(e.backtrace.join("\n"))
|
|
17
|
+
end
|
|
18
|
+
raise e
|
|
14
19
|
end
|
|
15
20
|
end
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: forest_admin_rails
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.12.
|
|
4
|
+
version: 1.12.1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Matthieu
|
|
@@ -68,6 +68,7 @@ files:
|
|
|
68
68
|
- app/controllers/forest_admin_rails/forest_controller.rb
|
|
69
69
|
- app/helpers/forest_admin_rails/application_helper.rb
|
|
70
70
|
- config/initializers/forest_admin_error_subscriber.rb
|
|
71
|
+
- config/initializers/forest_admin_route_cache.rb
|
|
71
72
|
- config/routes.rb
|
|
72
73
|
- lib/forest_admin_rails.rb
|
|
73
74
|
- lib/forest_admin_rails/engine.rb
|