Skip to content

fix: change &start and &end to "start" and "end" #240

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions rest/timer.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,13 @@ func (mw *TimerMiddleware) MiddlewareFunc(h HandlerFunc) HandlerFunc {
return func(w ResponseWriter, r *Request) {

start := time.Now()
r.Env["START_TIME"] = &start
r.Env["START_TIME"] = start

// call the handler
h(w, r)

end := time.Now()
elapsed := end.Sub(start)
r.Env["ELAPSED_TIME"] = &elapsed
r.Env["ELAPSED_TIME"] = elapsed
}
}
4 changes: 2 additions & 2 deletions rest/timer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ func TestTimerMiddleware(t *testing.T) {
if r.Env["ELAPSED_TIME"] == nil {
t.Error("ELAPSED_TIME is nil")
}
elapsedTime := r.Env["ELAPSED_TIME"].(*time.Duration)
elapsedTime := r.Env["ELAPSED_TIME"].(time.Duration)
if elapsedTime.Nanoseconds() <= 0 {
t.Errorf(
"ELAPSED_TIME is expected to be at least 1 nanosecond %d",
Expand All @@ -30,7 +30,7 @@ func TestTimerMiddleware(t *testing.T) {
if r.Env["START_TIME"] == nil {
t.Error("START_TIME is nil")
}
start := r.Env["START_TIME"].(*time.Time)
start := r.Env["START_TIME"].(time.Time)
if start.After(time.Now()) {
t.Errorf(
"START_TIME is expected to be in the past %s",
Expand Down