Skip to content

Commit

Permalink
apply metric
Browse files Browse the repository at this point in the history
  • Loading branch information
LikDan committed Mar 2, 2024
1 parent 1a343d0 commit 44ee555
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 2 deletions.
17 changes: 17 additions & 0 deletions .husky/hooks/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/bin/sh

go_test() {
go test -v ./...

# shellcheck disable=SC2181
if [ $? -ne 0 ]; then
echo "Tests failed."
exit 1
fi

echo "Tests passed successfully!"
}

go_test

exit 0
1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ require (
github.com/goccy/go-json v0.10.2 // indirect
github.com/golang/protobuf v1.5.3 // indirect
github.com/golang/snappy v0.0.3 // indirect
github.com/google/uuid v1.4.0 // indirect
github.com/hailocab/go-hostpool v0.0.0-20160125115350-e80d13ce29ed // indirect
github.com/jackc/pgpassfile v1.0.0 // indirect
github.com/jackc/pgservicefile v0.0.0-20221227161230-091c0ba34f0a // indirect
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/
github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI=
github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg=
github.com/google/uuid v1.4.0 h1:MtMxsa51/r9yyhkyLsVeVt0B+BGQZzpQiTQ4eHZ8bc4=
github.com/google/uuid v1.4.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
github.com/hailocab/go-hostpool v0.0.0-20160125115350-e80d13ce29ed h1:5upAirOpQc1Q53c0bnx2ufif5kANL7bfZWcc6VJWJd8=
github.com/hailocab/go-hostpool v0.0.0-20160125115350-e80d13ce29ed/go.mod h1:tMWxXQ9wFIaZeTI9F+hmhFiGpFmhOHzyShyFUhRm0H4=
github.com/jackc/pgpassfile v1.0.0 h1:/6Hmqy13Ss2zCq62VdNG8tM1wchn8zjSGOBJ6icpsIM=
Expand Down
6 changes: 5 additions & 1 deletion hc/overrides.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,11 @@ import (
)

func New() *Engine {
return &Engine{gin.New()}
g := gin.New()
return &Engine{
Engine: g,
IRoutes: ConvertIRoutesFromGin(g),
}
}

func Recovery() HandlerFunc {
Expand Down
1 change: 1 addition & 0 deletions hc/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
)

type Engine struct {
IRoutes
*gin.Engine
}

Expand Down
2 changes: 1 addition & 1 deletion http/metrics/handlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"github.com/stdyum/api-common/hc"
)

func ApplyMetrics(group *hc.RouterGroup) {
func ApplyMetrics(group hc.IRoutes) {
group.Any("/ping", ping)
group.GET("/metrics", metrics)
}

0 comments on commit 44ee555

Please sign in to comment.