File tree Expand file tree Collapse file tree 3 files changed +7
-4
lines changed
Expand file tree Collapse file tree 3 files changed +7
-4
lines changed Original file line number Diff line number Diff line change @@ -140,6 +140,7 @@ Date: Sun, 17 Aug 2014 13:26:05 GMT
140140Content-Length: 143
141141
142142{
143+ " duration" : 5356123
143144 " took" : " 5.356ms" ,
144145 " data" : {
145146 " Database settings" : {
Original file line number Diff line number Diff line change @@ -45,8 +45,9 @@ type Param struct {
4545
4646// Header is used to prepare a JSON header with duration triggered by UserTimer() method
4747type Header struct {
48- Took string `json:"took"`
49- Data interface {} `json:"data"`
48+ Duration time.Duration `json:"duration"`
49+ Took string `json:"took"`
50+ Data interface {} `json:"data"`
5051}
5152
5253// Get returns the first value associated with the given name.
@@ -87,7 +88,8 @@ func (c *Control) Body(data interface{}) {
8788 content = []byte (str )
8889 } else {
8990 if ! c .timer .IsZero () {
90- data = & Header {Took : time .Since (c .timer ).String (), Data : data }
91+ took := time .Now ()
92+ data = & Header {Duration : took .Sub (c .timer ), Took : took .Sub (c .timer ).String (), Data : data }
9193 }
9294 jsn , err := json .MarshalIndent (data , "" , " " )
9395 if err != nil {
Original file line number Diff line number Diff line change 33// license that can be found in the LICENSE file.
44
55/*
6- Package router 0.2.5 provides fast HTTP request router.
6+ Package router 0.2.6 provides fast HTTP request router.
77
88The router matches incoming requests by the request method and the path.
99If a handle is registered for this path and method, the router delegates the
You can’t perform that action at this time.
0 commit comments