cleanup: typo and code

This commit is contained in:
Ankit Patial
2024-10-12 20:57:57 +05:30
parent 8035c6f7af
commit d639ea1b71
2 changed files with 12 additions and 15 deletions

View File

@@ -2,6 +2,7 @@ package mux
import (
"context"
"errors"
"log/slog"
"net/http"
"os"
@@ -10,7 +11,7 @@ import (
type ServeCB func(srv *http.Server) error
// Serve with gracefull shutdown
// Serve with graceful shutdown
func (r *Router) Serve(cb ServeCB) {
srv := &http.Server{
Handler: r,
@@ -32,7 +33,7 @@ func (r *Router) Serve(cb ServeCB) {
close(idleConnsClosed)
}()
if err := cb(srv); err != http.ErrServerClosed {
if err := cb(srv); !errors.Is(err, http.ErrServerClosed) {
// Error starting or closing listener:
slog.Error("start server error", "error", err)
}