claude code review changes
This commit is contained in:
22
serve.go
22
serve.go
@@ -3,7 +3,6 @@ package mux
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"io"
|
||||
"log"
|
||||
"log/slog"
|
||||
"net"
|
||||
@@ -26,21 +25,6 @@ func (m *Mux) Serve(cb ServeCB) {
|
||||
rootCtx, stop := signal.NotifyContext(context.Background(), syscall.SIGINT, syscall.SIGTERM)
|
||||
defer stop()
|
||||
|
||||
// catch all options
|
||||
// lets get it thorugh all middlewares
|
||||
m.OPTIONS("/", func(w http.ResponseWriter, r *http.Request) {
|
||||
w.Header().Set("Content-Length", "0")
|
||||
if r.ContentLength != 0 {
|
||||
// Read up to 4KB of OPTIONS body (as mentioned in the
|
||||
// spec as being reserved for future use), but anything
|
||||
// over that is considered a waste of server resources
|
||||
// (or an attack) and we abort and close the connection,
|
||||
// courtesy of MaxBytesReader's EOF behavior.
|
||||
mb := http.MaxBytesReader(w, r.Body, 4<<10)
|
||||
io.Copy(io.Discard, mb)
|
||||
}
|
||||
})
|
||||
|
||||
srvCtx, cancelSrvCtx := context.WithCancel(context.Background())
|
||||
srv := &http.Server{
|
||||
Handler: m,
|
||||
@@ -51,7 +35,7 @@ func (m *Mux) Serve(cb ServeCB) {
|
||||
|
||||
go func() {
|
||||
if err := cb(srv); !errors.Is(err, http.ErrServerClosed) {
|
||||
panic(err)
|
||||
log.Fatalf("server error: %v", err)
|
||||
}
|
||||
}()
|
||||
|
||||
@@ -60,7 +44,7 @@ func (m *Mux) Serve(cb ServeCB) {
|
||||
|
||||
stop()
|
||||
m.IsShuttingDown.Store(true)
|
||||
slog.Info("received interrupt singal, shutting down")
|
||||
slog.Info("received interrupt signal, shutting down")
|
||||
time.Sleep(drainDelay)
|
||||
slog.Info("readiness check propagated, now waiting for ongoing requests to finish.")
|
||||
|
||||
@@ -74,5 +58,5 @@ func (m *Mux) Serve(cb ServeCB) {
|
||||
time.Sleep(shutdownHardDelay)
|
||||
}
|
||||
|
||||
slog.Info("seerver shut down gracefully")
|
||||
slog.Info("server shut down gracefully")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user