Fix lints
This commit is contained in:
parent
0f7fcaffdb
commit
5a03c74642
@ -15,8 +15,8 @@ const (
|
||||
)
|
||||
|
||||
type Timing struct {
|
||||
TimeMillis time.Duration `json:"timeMillis"`
|
||||
Source string `json:"source"`
|
||||
ExecutionTime time.Duration `json:"executionTime"`
|
||||
Source string `json:"source"`
|
||||
}
|
||||
|
||||
type HealthCheckResult struct {
|
||||
@ -43,8 +43,8 @@ func (app *Application) HealthCheck(w http.ResponseWriter, r *http.Request) {
|
||||
Time: time.Now().UTC(),
|
||||
Timing: []Timing{
|
||||
{
|
||||
Source: "HealthCheck",
|
||||
TimeMillis: time.Since(start),
|
||||
Source: "HealthCheck",
|
||||
ExecutionTime: time.Since(start),
|
||||
},
|
||||
},
|
||||
Response: HealthCheckResponse{
|
||||
|
@ -13,7 +13,7 @@ func (app *Application) Index(w http.ResponseWriter, r *http.Request) {
|
||||
reqId := RequestID(r)
|
||||
|
||||
err := indexTemplate.Execute(w, templateData{
|
||||
RequestID: reqId,
|
||||
RequestID: reqId,
|
||||
})
|
||||
if err != nil {
|
||||
l.Error().Err(err).Msg("error executing template")
|
||||
|
@ -1,6 +1,7 @@
|
||||
package handlers_test
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"net/http"
|
||||
"net/http/httptest"
|
||||
"testing"
|
||||
@ -35,7 +36,11 @@ func TestIndex(t *testing.T) {
|
||||
app.Handler().ServeHTTP(w, req)
|
||||
// app.Index(w, req)
|
||||
res := w.Result()
|
||||
defer res.Body.Close()
|
||||
defer func() {
|
||||
if err := res.Body.Close(); err != nil {
|
||||
fmt.Println("Received error: ", err)
|
||||
}
|
||||
}()
|
||||
|
||||
if res.StatusCode != 200 {
|
||||
t.Errorf("expected status to be 200, got %d", res.StatusCode)
|
||||
|
@ -14,7 +14,7 @@ func (app *Application) NotFound(w http.ResponseWriter, r *http.Request) {
|
||||
w.WriteHeader(http.StatusNotFound)
|
||||
|
||||
err := notFoundTemplate.Execute(w, templateData{
|
||||
RequestID: reqId,
|
||||
RequestID: reqId,
|
||||
})
|
||||
if err != nil {
|
||||
l.Error().Err(err).Msg("error executing template")
|
||||
|
@ -1,6 +1,7 @@
|
||||
package handlers_test
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"io"
|
||||
"net/http"
|
||||
"net/http/httptest"
|
||||
@ -16,7 +17,11 @@ func TestNotFound(t *testing.T) {
|
||||
|
||||
app.Handler().ServeHTTP(w, req)
|
||||
res := w.Result()
|
||||
defer res.Body.Close()
|
||||
defer func() {
|
||||
if err := res.Body.Close(); err != nil {
|
||||
fmt.Println("Received error: ", err)
|
||||
}
|
||||
}()
|
||||
|
||||
if res.StatusCode != 404 {
|
||||
t.Errorf("expected status to be 404, got %d", res.StatusCode)
|
||||
|
@ -10,7 +10,7 @@ var indexTemplate *template.Template
|
||||
var notFoundTemplate *template.Template
|
||||
|
||||
type templateData struct {
|
||||
RequestID string
|
||||
RequestID string
|
||||
}
|
||||
|
||||
func (app *Application) ParseTemplates() error {
|
||||
|
Loading…
x
Reference in New Issue
Block a user