Compare commits
6 Commits
2ac7f05e52
...
49ae3edfc4
Author | SHA1 | Date | |
---|---|---|---|
|
49ae3edfc4 | ||
a720477b16 | |||
5a03c74642 | |||
f8ae841245 | |||
|
6a710bf751 | ||
|
0f7fcaffdb |
@ -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@v6
|
uses: golangci/golangci-lint-action@v7
|
||||||
with:
|
with:
|
||||||
version: 'latest'
|
version: 'latest'
|
||||||
|
6
go.mod
6
go.mod
@ -5,13 +5,13 @@ 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.3
|
github.com/pelletier/go-toml/v2 v2.2.4
|
||||||
github.com/rs/zerolog v1.33.0
|
github.com/rs/zerolog v1.34.0
|
||||||
)
|
)
|
||||||
|
|
||||||
require (
|
require (
|
||||||
github.com/mattn/go-colorable v0.1.13 // indirect
|
github.com/mattn/go-colorable v0.1.13 // indirect
|
||||||
github.com/mattn/go-isatty v0.0.19 // indirect
|
github.com/mattn/go-isatty v0.0.19 // indirect
|
||||||
github.com/rs/xid v1.5.0 // indirect
|
github.com/rs/xid v1.6.0 // indirect
|
||||||
golang.org/x/sys v0.12.0 // indirect
|
golang.org/x/sys v0.12.0 // indirect
|
||||||
)
|
)
|
||||||
|
6
go.sum
6
go.sum
@ -11,11 +11,17 @@ 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=
|
||||||
|
github.com/rs/xid v1.6.0 h1:fV591PaemRlL6JfRxGDEPl69wICngIQ3shQtzfy2gxU=
|
||||||
|
github.com/rs/xid v1.6.0/go.mod h1:7XoLgs4eV+QndskICGsho+ADou8ySMSjJKDIan90Nz0=
|
||||||
github.com/rs/zerolog v1.33.0 h1:1cU2KZkvPxNyfgEmhHAz/1A9Bz+llsdYzklWFzgp0r8=
|
github.com/rs/zerolog v1.33.0 h1:1cU2KZkvPxNyfgEmhHAz/1A9Bz+llsdYzklWFzgp0r8=
|
||||||
github.com/rs/zerolog v1.33.0/go.mod h1:/7mN4D5sKwJLZQ2b/znpjC3/GQWY/xaDXUM0kKWRHss=
|
github.com/rs/zerolog v1.33.0/go.mod h1:/7mN4D5sKwJLZQ2b/znpjC3/GQWY/xaDXUM0kKWRHss=
|
||||||
|
github.com/rs/zerolog v1.34.0 h1:k43nTLIwcTVQAncfCw4KZ2VY6ukYoZaBPNOE8txlOeY=
|
||||||
|
github.com/rs/zerolog v1.34.0/go.mod h1:bJsvje4Z08ROH4Nhs5iH600c3IkWhwp44iRc54W6wYQ=
|
||||||
golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||||
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||||
golang.org/x/sys v0.12.0 h1:CM0HF96J0hcLAwsHPJZjfdNzs0gftsLfgKt57wWHJ0o=
|
golang.org/x/sys v0.12.0 h1:CM0HF96J0hcLAwsHPJZjfdNzs0gftsLfgKt57wWHJ0o=
|
||||||
|
@ -15,8 +15,8 @@ const (
|
|||||||
)
|
)
|
||||||
|
|
||||||
type Timing struct {
|
type Timing struct {
|
||||||
TimeMillis time.Duration `json:"timeMillis"`
|
ExecutionTime time.Duration `json:"executionTime"`
|
||||||
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",
|
||||||
TimeMillis: time.Since(start),
|
ExecutionTime: 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,6 +1,7 @@
|
|||||||
package handlers_test
|
package handlers_test
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"fmt"
|
||||||
"net/http"
|
"net/http"
|
||||||
"net/http/httptest"
|
"net/http/httptest"
|
||||||
"testing"
|
"testing"
|
||||||
@ -35,7 +36,11 @@ 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 res.Body.Close()
|
defer func() {
|
||||||
|
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,6 +1,7 @@
|
|||||||
package handlers_test
|
package handlers_test
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"net/http"
|
"net/http"
|
||||||
"net/http/httptest"
|
"net/http/httptest"
|
||||||
@ -16,7 +17,11 @@ func TestNotFound(t *testing.T) {
|
|||||||
|
|
||||||
app.Handler().ServeHTTP(w, req)
|
app.Handler().ServeHTTP(w, req)
|
||||||
res := w.Result()
|
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 {
|
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