Add blank HTML page at /rack-mini-profiler/requests (#396)

Add blank HTML page at /rack-mini-profiler/requests (#396)

  • add blank page at /rack-mini-profiler/requests

  • Update README.md

diff --git a/README.md b/README.md
index 1e9fe7e..56d3bc5 100644
--- a/README.md
+++ b/README.md
@@ -299,6 +299,9 @@ You need to inject the following in your SPA to load MiniProfiler's speed badge
 
 _Note:_ The GUID (`data-version` and the `?v=` parameter on the `src`) will change with each release of `rack_mini_profiler`. The MiniProfiler's speed badge will continue to work, although you will have to change the GUID to expire the script to fetch the most recent version.
 
+#### Using MiniProfiler's built in route for apps without HTML responses
+MiniProfiler also ships with a `/rack-mini-profiler/requests` route that displays the speed badge on a blank HTML page. This can be useful when profiling an application that does not render HTML.
+
 ### Configuration Options
 
 You can set configuration options using the configuration accessor on `Rack::MiniProfiler`.
diff --git a/lib/mini_profiler/profiler.rb b/lib/mini_profiler/profiler.rb
index a779c40..4bf53bb 100644
--- a/lib/mini_profiler/profiler.rb
+++ b/lib/mini_profiler/profiler.rb
@@ -331,6 +331,17 @@ module Rack
         return client_settings.handle_cookie(self.flamegraph(flamegraph))
       end
 
+      if path == '/rack-mini-profiler/requests'
+        blank_page_html = <<~HTML
+          <html>
+            <head></head>
+            <body></body>
+          </html>
+        HTML
+
+        status, headers, body = [200, { 'Content-Type' => 'text/html' }, [blank_page_html.dup]]
+      end
+
       begin
         @storage.save(page_struct)
         # no matter what it is, it should be unviewed, otherwise we will miss POST

GitHub sha: a95ccd3b