Monday, May 20, 2024
HomeGolangGin print query_time as variable - Getting Assist

Gin print query_time as variable – Getting Assist


I need my frontend to show the time a request took to course of.

ATM I do it like this:

t_start := time.Now()
t_end := time.Since(t_start)

Then I go it as a variable to the template.
However since I take advantage of Gin and it each time logs all the things already with exact instances, I’d like to get the question time from Gin and go it to the template.

I need to do that for 2 causes:

  1. not making golang do issues twice.
  2. having extra exact instances, as once I examine the instances, my very own calculated instances are slightly off and never very exact.
  3. the time for rendering the template isn’t included.

Is there a simple manner like storing gins logger time in a variable, which I can entry excellent earlier than c.HTML(200, "essential.html", p) so I can go it on as a variable?

Thanks prematurely!

This matter was routinely closed 90 days after the final reply. New replies are not allowed.

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Most Popular

Recent Comments