Skip to content

Commit

Permalink
fix: httpErr always non-nil
Browse files Browse the repository at this point in the history
  • Loading branch information
fosmjo committed May 31, 2024
1 parent 4c52b97 commit 428a9b3
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions middleware.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,11 @@ package slogecho
import (
"context"
"errors"
"log/slog"
"net/http"
"strings"
"time"

"log/slog"

"github.com/labstack/echo/v4"
"github.com/samber/lo"
"go.opentelemetry.io/otel/trace"
Expand Down Expand Up @@ -141,7 +140,7 @@ func NewWithConfig(logger *slog.Logger, config Config) echo.MiddlewareFunc {
ip := c.RealIP()
referer := c.Request().Referer()

httpErr := new(echo.HTTPError)
var httpErr *echo.HTTPError
if err != nil && errors.As(err, &httpErr) {
status = httpErr.Code
if msg, ok := httpErr.Message.(string); ok {
Expand Down

0 comments on commit 428a9b3

Please sign in to comment.