Glimpse.Prototype icon indicating copy to clipboard operation
Glimpse.Prototype copied to clipboard

Inject Glimpse Scripts Without Razor Dependency

Open nikmd23 opened this issue 10 years ago • 2 comments

For ASP.NET5 users who aren't using Razor, we may want to provide a solution that automatically injects the Glimpse script tabs via a wrapper around the response stream.

The following considerations need to be taken into account:

  • if the content length has been set and the response has started (which we can check) then we WONT want to modify the response,
  • if the content length has been set and the response has not started then we can inject the script and update the content length,
  • if they are running “in app” compression (i.e. via middleware) we should be able to look to see if the corresponding header has been set and not write to the stream,
  • if they are leveraging the server to do the compression, we are good just to write to the stream
  • any other time out side of these cases we should be good to write to the stream. All of this assuming content type is HTML
  • If the request is AJAX, then we don’t want to write to the stream.
  • Technically if the response doesn’t have a

tag, then we don’t want to write to it either, but that case may be covered by the AJAX logic above.

  • If the doctype if XHTML, we shouldn’t be injecting either. This would break API’s that use this doctype. Technically, that content should be served with the content type of application/xhtml+xml.
  • nikmd23 avatar Oct 19 '15 21:10 nikmd23

    Hi @nikmd23 , I would like to know if you have already started to address this issue / enhancement of the GlimpseAgentMiddleware ? I've just installed the 2.0.0-beta1 version along with aspnet5-1.0.0-rc1 and the client works like a charm on a web api ! That would be great if we could have the HUD directly injected in the page when we browse api responses or HTML's static pages. I searched through sources a way to plug a middleware as you described but I find it better to ask you some informations before starting anything. Thank you, let me know if I can help !

    emyann avatar Nov 30 '15 02:11 emyann

    Hi @emyann!

    Thanks for showing interest in contributing to Glimpse.

    We have not started this work. We have a similar idea in Glimpse v1 that might serve as a starting point.

    As far as where this would be implemented in Glimpse v2, I would think we'd start by looking at GlimpseAgentMiddleware.

    nikmd23 avatar Nov 30 '15 23:11 nikmd23