Skip to content

Commit a1fec18

Browse files
authored
feat: Serve the health path from the recording and replaying servers. (#10)
When a health check path is configured for a endpoint using the `health` key, test-server will respond to that path with a 200 HTTP status.
1 parent bc9b692 commit a1fec18

3 files changed

Lines changed: 10 additions & 0 deletions

File tree

internal/config/config.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ type EndpointConfig struct {
2929
TargetPort int64 `yaml:"target_port"`
3030
SourcePort int64 `yaml:"source_port"`
3131
SourceType string `yaml:"source_type"`
32+
Health string `yaml:"health"`
3233
RedactRequestHeaders []string `yaml:"redact_request_headers"`
3334
ResponseHeaderReplacements []HeaderReplacement `yaml:"response_header_replacements"`
3435
}

internal/record/recording_https_proxy.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,10 @@ func (r *RecordingHTTPSProxy) Start() error {
6464
}
6565

6666
func (r *RecordingHTTPSProxy) handleRequest(w http.ResponseWriter, req *http.Request) {
67+
if req.URL.Path == r.config.Health {
68+
w.WriteHeader(http.StatusOK)
69+
return
70+
}
6771
fmt.Printf("Recording request: %s %s\n", req.Method, req.URL.String())
6872

6973
reqHash, err := r.recordRequest(req)

internal/replay/replay_http_server.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,11 @@ func (r *ReplayHTTPServer) Start() error {
5656
}
5757

5858
func (r *ReplayHTTPServer) handleRequest(w http.ResponseWriter, req *http.Request) {
59+
if req.URL.Path == r.config.Health {
60+
w.WriteHeader(http.StatusOK)
61+
return
62+
}
63+
5964
redactedReq, err := r.createRedactedRequest(req)
6065
if err != nil {
6166
fmt.Printf("Error processing request")

0 commit comments

Comments
 (0)