feat(mail): send service identity mail through a leased worker

This commit is contained in:
shira committed 2026-10-06 21:08:11 +03:00
1 parent 204c6bae62
commit d21fd49a42
58 files changed
+7577 -164

No files matched your search

@@ -0,0 +1,29 @@
package resend
import (
"errors"
"net"
"net/url"
"time"
)
// NewLoopbackSender builds the transport against a Resend API fixture that
// runs on this machine, for tests of the delivery layer. It accepts only an
// http URL whose host is a loopback address, so the API key and the messages
// of a deployment can never be pointed at another host through it; the
// bootstrap code uses NewSender and its fixed endpoint.
func NewLoopbackSender(apiKey, from string, timeout time.Duration, endpoint string, now func() time.Time) (*Sender, error) {
target, err := url.Parse(endpoint)
if err != nil || target.Scheme != "http" || !isLoopbackHost(target.Hostname()) {
return nil, errors.New("resend.NewLoopbackSender - endpoint must be an http URL on a loopback address")
}
return newSender(apiKey, from, timeout, endpoint, now)
}
func isLoopbackHost(host string) bool {
if host == "localhost" {
return true
}
address := net.ParseIP(host)
return address != nil && address.IsLoopback()
}