Compare commits
1 Commits
49ae3edfc4
...
2ac7f05e52
Author | SHA1 | Date | |
---|---|---|---|
|
2ac7f05e52 |
@ -15,6 +15,6 @@ jobs:
|
|||||||
with:
|
with:
|
||||||
go-version-file: 'go.mod'
|
go-version-file: 'go.mod'
|
||||||
- name: golangci-lint
|
- name: golangci-lint
|
||||||
uses: golangci/golangci-lint-action@v7
|
uses: golangci/golangci-lint-action@v6
|
||||||
with:
|
with:
|
||||||
version: 'latest'
|
version: 'latest'
|
||||||
|
2
go.mod
2
go.mod
@ -5,7 +5,7 @@ go 1.22.6
|
|||||||
require (
|
require (
|
||||||
github.com/gorilla/mux v1.8.1
|
github.com/gorilla/mux v1.8.1
|
||||||
github.com/justinas/alice v1.2.0
|
github.com/justinas/alice v1.2.0
|
||||||
github.com/pelletier/go-toml/v2 v2.2.4
|
github.com/pelletier/go-toml/v2 v2.2.3
|
||||||
github.com/rs/zerolog v1.34.0
|
github.com/rs/zerolog v1.34.0
|
||||||
)
|
)
|
||||||
|
|
||||||
|
2
go.sum
2
go.sum
@ -11,8 +11,6 @@ github.com/mattn/go-isatty v0.0.19 h1:JITubQf0MOLdlGRuRq+jtsDlekdYPia9ZFsB8h/APP
|
|||||||
github.com/mattn/go-isatty v0.0.19/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y=
|
github.com/mattn/go-isatty v0.0.19/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y=
|
||||||
github.com/pelletier/go-toml/v2 v2.2.3 h1:YmeHyLY8mFWbdkNWwpr+qIL2bEqT0o95WSdkNHvL12M=
|
github.com/pelletier/go-toml/v2 v2.2.3 h1:YmeHyLY8mFWbdkNWwpr+qIL2bEqT0o95WSdkNHvL12M=
|
||||||
github.com/pelletier/go-toml/v2 v2.2.3/go.mod h1:MfCQTFTvCcUyyvvwm1+G6H/jORL20Xlb6rzQu9GuUkc=
|
github.com/pelletier/go-toml/v2 v2.2.3/go.mod h1:MfCQTFTvCcUyyvvwm1+G6H/jORL20Xlb6rzQu9GuUkc=
|
||||||
github.com/pelletier/go-toml/v2 v2.2.4 h1:mye9XuhQ6gvn5h28+VilKrrPoQVanw5PMw/TB0t5Ec4=
|
|
||||||
github.com/pelletier/go-toml/v2 v2.2.4/go.mod h1:2gIqNv+qfxSVS7cM2xJQKtLSTLUE9V8t9Stt+h56mCY=
|
|
||||||
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
|
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
|
||||||
github.com/rs/xid v1.5.0 h1:mKX4bl4iPYJtEIxp6CYiUuLQ/8DYMoz0PUdtGgMFRVc=
|
github.com/rs/xid v1.5.0 h1:mKX4bl4iPYJtEIxp6CYiUuLQ/8DYMoz0PUdtGgMFRVc=
|
||||||
github.com/rs/xid v1.5.0/go.mod h1:trrq9SKmegXys3aeAKXMUTdJsYXVwGY3RLcfgqegfbg=
|
github.com/rs/xid v1.5.0/go.mod h1:trrq9SKmegXys3aeAKXMUTdJsYXVwGY3RLcfgqegfbg=
|
||||||
|
@ -15,8 +15,8 @@ const (
|
|||||||
)
|
)
|
||||||
|
|
||||||
type Timing struct {
|
type Timing struct {
|
||||||
ExecutionTime time.Duration `json:"executionTime"`
|
TimeMillis time.Duration `json:"timeMillis"`
|
||||||
Source string `json:"source"`
|
Source string `json:"source"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type HealthCheckResult struct {
|
type HealthCheckResult struct {
|
||||||
@ -43,8 +43,8 @@ func (app *Application) HealthCheck(w http.ResponseWriter, r *http.Request) {
|
|||||||
Time: time.Now().UTC(),
|
Time: time.Now().UTC(),
|
||||||
Timing: []Timing{
|
Timing: []Timing{
|
||||||
{
|
{
|
||||||
Source: "HealthCheck",
|
Source: "HealthCheck",
|
||||||
ExecutionTime: time.Since(start),
|
TimeMillis: time.Since(start),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
Response: HealthCheckResponse{
|
Response: HealthCheckResponse{
|
||||||
|
@ -13,7 +13,7 @@ func (app *Application) Index(w http.ResponseWriter, r *http.Request) {
|
|||||||
reqId := RequestID(r)
|
reqId := RequestID(r)
|
||||||
|
|
||||||
err := indexTemplate.Execute(w, templateData{
|
err := indexTemplate.Execute(w, templateData{
|
||||||
RequestID: reqId,
|
RequestID: reqId,
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
l.Error().Err(err).Msg("error executing template")
|
l.Error().Err(err).Msg("error executing template")
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
package handlers_test
|
package handlers_test
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
|
||||||
"net/http"
|
"net/http"
|
||||||
"net/http/httptest"
|
"net/http/httptest"
|
||||||
"testing"
|
"testing"
|
||||||
@ -36,11 +35,7 @@ func TestIndex(t *testing.T) {
|
|||||||
app.Handler().ServeHTTP(w, req)
|
app.Handler().ServeHTTP(w, req)
|
||||||
// app.Index(w, req)
|
// app.Index(w, req)
|
||||||
res := w.Result()
|
res := w.Result()
|
||||||
defer func() {
|
defer res.Body.Close()
|
||||||
if err := res.Body.Close(); err != nil {
|
|
||||||
fmt.Println("Received error: ", err)
|
|
||||||
}
|
|
||||||
}()
|
|
||||||
|
|
||||||
if res.StatusCode != 200 {
|
if res.StatusCode != 200 {
|
||||||
t.Errorf("expected status to be 200, got %d", res.StatusCode)
|
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)
|
w.WriteHeader(http.StatusNotFound)
|
||||||
|
|
||||||
err := notFoundTemplate.Execute(w, templateData{
|
err := notFoundTemplate.Execute(w, templateData{
|
||||||
RequestID: reqId,
|
RequestID: reqId,
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
l.Error().Err(err).Msg("error executing template")
|
l.Error().Err(err).Msg("error executing template")
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
package handlers_test
|
package handlers_test
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
|
||||||
"io"
|
"io"
|
||||||
"net/http"
|
"net/http"
|
||||||
"net/http/httptest"
|
"net/http/httptest"
|
||||||
@ -17,11 +16,7 @@ func TestNotFound(t *testing.T) {
|
|||||||
|
|
||||||
app.Handler().ServeHTTP(w, req)
|
app.Handler().ServeHTTP(w, req)
|
||||||
res := w.Result()
|
res := w.Result()
|
||||||
defer func() {
|
defer res.Body.Close()
|
||||||
if err := res.Body.Close(); err != nil {
|
|
||||||
fmt.Println("Received error: ", err)
|
|
||||||
}
|
|
||||||
}()
|
|
||||||
|
|
||||||
if res.StatusCode != 404 {
|
if res.StatusCode != 404 {
|
||||||
t.Errorf("expected status to be 404, got %d", res.StatusCode)
|
t.Errorf("expected status to be 404, got %d", res.StatusCode)
|
||||||
|
@ -10,7 +10,7 @@ var indexTemplate *template.Template
|
|||||||
var notFoundTemplate *template.Template
|
var notFoundTemplate *template.Template
|
||||||
|
|
||||||
type templateData struct {
|
type templateData struct {
|
||||||
RequestID string
|
RequestID string
|
||||||
}
|
}
|
||||||
|
|
||||||
func (app *Application) ParseTemplates() error {
|
func (app *Application) ParseTemplates() error {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user