Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -161,8 +161,6 @@ arithsrvClient := arithsrv.NewClient(arithsrvUrl, appkit.NewHTTPClient("arithsrv
- `DebugIDFromContext(ctx context.Context) uint64` - Retrieves debug ID from context
- `NewSQLGroupContext(ctx context.Context, group string) context.Context` - Creates context with SQL group for debug logging
- `SQLGroupFromContext(ctx context.Context) string` - Retrieves SQL group from context
- `NewSentryHubContext(ctx context.Context, sentryHub *sentry.Hub) context.Context` - Creates context with Sentry Hub
- `SentryHubFromContext(ctx context.Context) (*sentry.Hub, bool)` - Retrieves Sentry Hub from context
- `NewIPContext(ctx context.Context, ip string) context.Context` - Creates context with IP address
- `IPFromContext(ctx context.Context) string` - Retrieves IP address from context
- `NewUserAgentContext(ctx context.Context, ua string) context.Context` - Creates context with User-Agent
Expand Down
3 changes: 2 additions & 1 deletion handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"slices"
"strings"

"github.com/getsentry/sentry-go"
sentryecho "github.com/getsentry/sentry-go/echo"
"github.com/labstack/echo/v4"
)
Expand Down Expand Up @@ -84,7 +85,7 @@ func EchoIPContext() echo.MiddlewareFunc {
func applySentryHubToContext(c echo.Context) echo.Context {
if hub := sentryecho.GetHubFromContext(c); hub != nil {
req := c.Request()
c.SetRequest(req.WithContext(NewSentryHubContext(req.Context(), hub)))
c.SetRequest(req.WithContext(sentry.SetHubOnContext(req.Context(), hub)))
}
return c
}
Expand Down
17 changes: 0 additions & 17 deletions middleware.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@ package appkit

import (
"context"

"github.com/getsentry/sentry-go"
)

const (
Expand All @@ -15,7 +13,6 @@ const (
ctxUserAgentKey contextKey = "userAgent"
ctxCountryKey contextKey = "country"
ctxNotificationKey string = "JSONRPC2-Notification"
ctxSentryHubKey contextKey = "sentryHub"
debugIDCtx contextKey = "debugID"
sqlGroupCtx contextKey = "sqlGroup"

Expand Down Expand Up @@ -59,20 +56,6 @@ func SQLGroupFromContext(ctx context.Context) string {
return r
}

// NewSentryHubContext creates new context with Sentry Hub.
func NewSentryHubContext(ctx context.Context, sentryHub *sentry.Hub) context.Context {
if sentryHub == nil {
return ctx
}
return context.WithValue(ctx, ctxSentryHubKey, sentryHub)
}

// SentryHubFromContext returns Sentry Hub from context.
func SentryHubFromContext(ctx context.Context) (*sentry.Hub, bool) {
r, ok := ctx.Value(ctxSentryHubKey).(*sentry.Hub)
return r, ok
}

// NewIPContext creates new context with IP.
func NewIPContext(ctx context.Context, ip string) context.Context {
return context.WithValue(ctx, ctxIPKey, ip)
Expand Down