httpsender

package
v0.6.6 Latest Latest
Warning

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

Go to latest
Published: May 7, 2024 License: Apache-2.0, MIT Imports: 14 Imported by: 5

Documentation

Index

Constants

View Source
const DefaultAnnouncePath = "/announce"

Variables

This section is empty.

Functions

This section is empty.

Types

type Option

type Option func(*config) error

Option is a function that sets a value in a config.

func WithClient

func WithClient(c *http.Client) Option

WithClient uses an existing http.Client with the Sender.

func WithExtraData added in v0.3.0

func WithExtraData(data []byte) Option

WithExtraData sets the extra data to include in the announce message.

func WithTimeout

func WithTimeout(timeout time.Duration) Option

WithTimeout configures the timeout to wait for a response.

func WithUserAgent added in v0.2.3

func WithUserAgent(userAgent string) Option

WithUserAgent sets the value used for the User-Agent header.

type Sender

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

Sender sends announce messages over HTTP.

func New

func New(announceURLs []*url.URL, peerID peer.ID, options ...Option) (*Sender, error)

New creates a new Sender that sends advertisement announcement messages over HTTP. Announcements are sent directly to the specified URLs. The specified peerID is added to the multiaddrs contained in the announcements, which is how the publisher ID is communicated over HTTP.

func (*Sender) Close

func (s *Sender) Close() error

Close closes idle HTTP connections.

func (*Sender) Send

func (s *Sender) Send(ctx context.Context, msg message.Message) error

Send sends the Message to the announce URLs.

func (*Sender) SendJson

func (s *Sender) SendJson(ctx context.Context, msg message.Message) error

Jump to

Keyboard shortcuts

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