Skip to content

Commit

Permalink
[v1.4.1] Allow disable crash
Browse files Browse the repository at this point in the history
  • Loading branch information
troydai committed Nov 29, 2024
1 parent c85667b commit 56bf17f
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions internal/http/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,11 @@ type Server struct {

func (s *Server) HandleHTTP(w http.ResponseWriter, r *http.Request) {
s.logger.Info("inbound", "method", r.Method, "url", r.URL.Path, "host", r.Host, "proto", r.Proto, "agent", r.UserAgent(), "peer", r.RemoteAddr, "counter", s.counter.Load())
newCount := s.counter.Add(1)

if newValue := s.counter.Add(1); newValue%s.frequency == 0 {
s.logger.Warn("crash", "counter", newValue)
panic("crash after 10 requests")
if s.frequency != 0 && newCount%s.frequency == 0 {
s.logger.Warn("crash", "counter", newCount)
panic("crash as requested")
}

s.logger.Info("outbound", "status", 200)
Expand Down

0 comments on commit 56bf17f

Please sign in to comment.