Skip to content

Commit

Permalink
Fix the extra noise in logs with HealthChecker (issue #575)
Browse files Browse the repository at this point in the history
  • Loading branch information
tarampampam committed Nov 5, 2024
1 parent 7bc09a8 commit d83a185
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 1 deletion.
11 changes: 11 additions & 0 deletions compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,16 @@ services:
depends_on: {app-web-dist: {condition: service_healthy}}
security_opt: [no-new-privileges:true]

redis:
image: docker.io/library/redis:7-alpine
volumes: [redis-data:/data:rw]
ports: ['6379/tcp']
healthcheck:
test: ['CMD', 'redis-cli', 'ping']
interval: 500ms
timeout: 1s
security_opt: [no-new-privileges:true]

k6:
image: ghcr.io/grafana/k6:latest
volumes: [.:/src:ro]
Expand All @@ -45,3 +55,4 @@ services:
volumes:
app-modules-cache: {}
app-tmp-data: {}
redis-data: {}
19 changes: 19 additions & 0 deletions internal/http/openapi/configs/server.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,22 @@ generate:
std-http-server: true
#echo-server: true
#strict-server: true

output-options:
user-templates:
stdhttp/std-http-interface.tmpl: | # Original source: https://bit.ly/40EkPHr
// ServerInterface represents all server handlers.
type ServerInterface interface {
{{range .}}{{.SummaryAsComment }}
// ({{.Method}} {{.Path}})
{{.OperationId}}(w http.ResponseWriter, r *http.Request{{genParamArgs .PathParams}}{{if .RequiresParamObject}}, params {{.OperationId}}Params{{end}})
{{end}}
}
{{- /* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! CUSTOM CODE BEGIN !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! */}}
const (
{{ range . -}}
Route{{.OperationId}} = "{{ .Path | swaggerUriToStdHttpUri }}"
{{ end }}
)
{{- /* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! CUSTOM CODE END !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! */}}
5 changes: 4 additions & 1 deletion internal/http/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,10 @@ func (s *Server) Register(
}))

// apply middlewares
s.http.Handler = logreq.New(log, nil)( // logger middleware
s.http.Handler = logreq.New(log, func(r *http.Request) bool {
// issue: https://github.com/tarampampam/webhook-tester/issues/575
return r.URL.Path == openapi.RouteLivenessProbe || r.URL.Path == openapi.RouteReadinessProbe
})( // logger middleware
webhook.New(ctx, log.Named("webhook"), db, pubSub, cfg)( // webhook capture as a middleware
handler,
),
Expand Down

0 comments on commit d83a185

Please sign in to comment.