Skip to content

Conversation

@mr-linch
Copy link
Owner

@mr-linch mr-linch commented Nov 14, 2023

Allow to modify default behavior of IP extraction from http.Request.

e.g. using use Cf-Connection-Ip

webhook := tgb.NewWebhook(
	handler,
	client,
	"https://example.com/webhook",
	tgb.WithWebhookRequestIP(func(r *http.Request) string {
		ip := r.Header.Get("Cf-Connecting-Ip")

		if ip != "" {
			return ip
		}

		return tgb.DefaultWebhookRequestIP(r)
	}),
)

@codecov
Copy link

codecov bot commented Nov 14, 2023

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (114f0b5) 93.15% compared to head (6f82339) 93.17%.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #133      +/-   ##
==========================================
+ Coverage   93.15%   93.17%   +0.01%     
==========================================
  Files          20       20              
  Lines        2426     2432       +6     
==========================================
+ Hits         2260     2266       +6     
  Misses        130      130              
  Partials       36       36              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@mr-linch mr-linch merged commit 26f40ef into main Nov 14, 2023
@mr-linch mr-linch deleted the webhook-custom-ip-func branch November 14, 2023 18:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants