Inject Glimpse Scripts Without Razor Dependency
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.
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 !
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.