gateway

package
v1.1.7 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 18, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package gateway provides an embedded SDK for the message gateway.

Usage:

gw, err := gateway.New(gateway.Config{
    DefaultEmailProvider: "memory",
})

result, err := gw.SendEmail(ctx, &contracts.Email{
    To:      []string{"user@example.com"},
    Subject: "Hello",
    HTML:    "<p>World</p>",
})

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ChatConfig added in v1.1.2

type ChatConfig = registry.ChatConfig

Type aliases for SDK users - these reference the canonical registry types. Users can use either gateway.EmailConfig or registry.EmailConfig.

type CommonConfig added in v1.1.2

type CommonConfig = registry.CommonConfig

Type aliases for SDK users - these reference the canonical registry types. Users can use either gateway.EmailConfig or registry.EmailConfig.

type Config

type Config struct {
	DefaultEmailProvider string
	DefaultSMSProvider   string
	DefaultPushProvider  string
	DefaultChatProvider  string

	// Provider-specific configurations keyed by provider name.
	// Uses registry types as single source of truth.
	EmailProviders map[string]registry.EmailConfig
	SMSProviders   map[string]registry.SMSConfig
	PushProviders  map[string]registry.PushConfig
	ChatProviders  map[string]registry.ChatConfig

	// MailpitEnabled enables SMTP forwarding for the memory provider.
	MailpitEnabled bool
}

Config holds the gateway configuration.

type EmailConfig added in v1.1.2

type EmailConfig = registry.EmailConfig

Type aliases for SDK users - these reference the canonical registry types. Users can use either gateway.EmailConfig or registry.EmailConfig.

type Gateway

type Gateway struct {
	// contains filtered or unexported fields
}

Gateway is the main entry point for sending messages.

func New

func New(cfg Config) (*Gateway, error)

New creates a new Gateway instance.

func (*Gateway) SendChat

func (g *Gateway) SendChat(ctx context.Context, chat *contracts.ChatMessage) (*contracts.SendResult, error)

SendChat sends a chat message using the default provider.

func (*Gateway) SendChatWith

func (g *Gateway) SendChatWith(ctx context.Context, provider string, chat *contracts.ChatMessage) (*contracts.SendResult, error)

SendChatWith sends a chat message using a specific provider.

func (*Gateway) SendEmail

func (g *Gateway) SendEmail(ctx context.Context, email *contracts.Email) (*contracts.SendResult, error)

SendEmail sends an email using the default provider.

func (*Gateway) SendEmailWith

func (g *Gateway) SendEmailWith(ctx context.Context, provider string, email *contracts.Email) (*contracts.SendResult, error)

SendEmailWith sends an email using a specific provider.

func (*Gateway) SendPush

SendPush sends a push notification using the default provider.

func (*Gateway) SendPushWith

func (g *Gateway) SendPushWith(ctx context.Context, provider string, push *contracts.PushNotification) (*contracts.SendResult, error)

SendPushWith sends a push notification using a specific provider.

func (*Gateway) SendSMS

func (g *Gateway) SendSMS(ctx context.Context, sms *contracts.SMS) (*contracts.SendResult, error)

SendSMS sends an SMS using the default provider.

func (*Gateway) SendSMSWith

func (g *Gateway) SendSMSWith(ctx context.Context, provider string, sms *contracts.SMS) (*contracts.SendResult, error)

SendSMSWith sends an SMS using a specific provider.

type PushConfig added in v1.1.2

type PushConfig = registry.PushConfig

Type aliases for SDK users - these reference the canonical registry types. Users can use either gateway.EmailConfig or registry.EmailConfig.

type SMSConfig added in v1.1.2

type SMSConfig = registry.SMSConfig

Type aliases for SDK users - these reference the canonical registry types. Users can use either gateway.EmailConfig or registry.EmailConfig.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL