These are chat archives for gin-gonic/gin

16th
Apr 2016
Rıza Sabuncu
@riza
Apr 16 2016 23:14
Hi,
how to get response time on gingonic?
Ousmane Traore
@otraore
Apr 16 2016 23:14
How long it took for the response to finish?
Rıza Sabuncu
@riza
Apr 16 2016 23:15
yes
in console
example
[GIN] 2016/04/17 - 02:07:16 | 200 | 737.579µs | 127.0.0.1 | GET /
how to get on html 737.579µs
?
Ousmane Traore
@otraore
Apr 16 2016 23:16
Where?
You can't really get it in the handler because the response hasn't been sent yet.
Rıza Sabuncu
@riza
Apr 16 2016 23:17
mm
Ousmane Traore
@otraore
Apr 16 2016 23:17
Where do you want to access it?
Or what do you want to access it for?
Rıza Sabuncu
@riza
Apr 16 2016 23:18
i want page load time
Ousmane Traore
@otraore
Apr 16 2016 23:18
Maybe I can recommend something else?
ooh
One second
Rıza Sabuncu
@riza
Apr 16 2016 23:18
:)
Ousmane Traore
@otraore
Apr 16 2016 23:19
Give me a second I'm going to try out a solution I have in mind
Rıza Sabuncu
@riza
Apr 16 2016 23:19
okkay:)
thanks:)
its correct?
Ousmane Traore
@otraore
Apr 16 2016 23:41
When c.Next() is called
your actual handler is called
That means when the execution gets to end := time.Now() the response has already been sent
so you can't really add something to an already sent response
Rıza Sabuncu
@riza
Apr 16 2016 23:42
mm
Ousmane Traore
@otraore
Apr 16 2016 23:43
Also, are you using the material theme by any chance?
On your editor
Rıza Sabuncu
@riza
Apr 16 2016 23:43
yeap
Matthias Loibl
@metalmatze
Apr 16 2016 23:43
I know the people from gogits/gogs have something similar on their site.
Rıza Sabuncu
@riza
Apr 16 2016 23:44
can you edit my function
for real time?
Ousmane Traore
@otraore
Apr 16 2016 23:44
Yes
Second
Rıza Sabuncu
@riza
Apr 16 2016 23:44
Sublime text
3
Matthias Loibl
@metalmatze
Apr 16 2016 23:44
But I personally, find that message as a user rather annyoing.
Matthias Loibl
@metalmatze
Apr 16 2016 23:45
Check the bottom of the page: https://try.gogs.io/
Ousmane Traore
@otraore
Apr 16 2016 23:45
I think it's because gogs is using a js frontend
So they can see response time from the js request
Rıza Sabuncu
@riza
Apr 16 2016 23:46
mm
Thomas Boerger
@tboerger
Apr 16 2016 23:46
gogs doesnt use much js
Matthias Loibl
@metalmatze
Apr 16 2016 23:46
@otraore You're right. It's not working after disabling javascript!
Thomas Boerger
@tboerger
Apr 16 2016 23:48
@MetalMatze it’s still working with js disabled. it’s pure serverside
but they are not usin gin anyway
Matthias Loibl
@metalmatze
Apr 16 2016 23:48
What? Really. It just showed 0ms the 5 times I reloaded. Damn caches!
Thomas Boerger
@tboerger
Apr 16 2016 23:49
go to https://try.gogs.io/explore/repos and try again
Matthias Loibl
@metalmatze
Apr 16 2016 23:49
@tboerger I know they aren't using gin. But I wanted to point to that project as a reference that they might have the source available.
Thomas Boerger
@tboerger
Apr 16 2016 23:49
:)
gn8
Ousmane Traore
@otraore
Apr 16 2016 23:59
I'm not sure how gogits did it but now that I think about it, I don't think you can accurately get load time really of the WHOLE response without a combination of a middleware (start of request) and some form of end-ware that's called right before the response is actually sent out