Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
caddy
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
caddy
Commits
95dce5cd
Commit
95dce5cd
authored
Apr 23, 2015
by
Matthew Holt
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Latency now available with recorder and replacer
parent
51139a5f
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
9 additions
and
3 deletions
+9
-3
middleware/recorder.go
middleware/recorder.go
+6
-1
middleware/replacer.go
middleware/replacer.go
+3
-2
No files found.
middleware/recorder.go
View file @
95dce5cd
package
middleware
import
"net/http"
import
(
"net/http"
"time"
)
// responseRecorder is a type of ResponseWriter that captures
// the status code written to it and also the size of the body
...
...
@@ -12,6 +15,7 @@ type responseRecorder struct {
http
.
ResponseWriter
status
int
size
int
start
time
.
Time
}
// NewResponseRecorder makes and returns a new responseRecorder,
...
...
@@ -24,6 +28,7 @@ func NewResponseRecorder(w http.ResponseWriter) *responseRecorder {
return
&
responseRecorder
{
ResponseWriter
:
w
,
status
:
http
.
StatusOK
,
start
:
time
.
Now
(),
}
}
...
...
middleware/replacer.go
View file @
95dce5cd
...
...
@@ -52,6 +52,7 @@ func NewReplacer(r *http.Request, rr *responseRecorder) replacer {
}(),
"{status}"
:
strconv
.
Itoa
(
rr
.
status
),
"{size}"
:
strconv
.
Itoa
(
rr
.
size
),
"{latency}"
:
time
.
Since
(
rr
.
start
)
.
String
(),
}
// Header placeholders
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment