httpu

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Apr 6, 2023 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultMaxMessageBytes = 2048
)
View Source
const DefaultTimeout = 10 * time.Second
View Source
const LocalAddressHeader = "X-local-address"

Variables

This section is empty.

Functions

func Serve

func Serve(ctx context.Context, conn *ipv4.PacketConn, handler Handler) error

Serve messages received on the given packet listener to the given handler.

func WriteRequest

func WriteRequest(wr io.Writer, req *http.Request) error

func WriteResponse

func WriteResponse(wr io.Writer, res *http.Response) error

Types

type Client

type Client interface {
	io.Closer

	// Do sends the request and returns the responses. numSends controls the number of times the request is sent.
	Do(ctx context.Context, req *http.Request, numSends int) ([]*http.Response, error)
}

Client is an interface for sending HTTP over UDP requests and receive responses.

func NewClientAddr

func NewClientAddr(addr string) (Client, error)

NewClientAddr creates a new HTTPUClient which will broadcast packets from the specified address, opening up a new UDP socket for the purpose

func NewClientInterfaces

func NewClientInterfaces(interfaceList []net.Interface) (Client, error)

NewClientInterfaces creates a SSDP client that multiplexes to all multicast-capable IPv4 addresses on the host. Returns a function to clean up once the client is no longer required.

func NewHTTPUClient

func NewHTTPUClient() (Client, error)

func NewMultiClient

func NewMultiClient(delegates []Client) Client

type Handler

type Handler interface {
	// ServeMessage is called for each SSDP message received. peerAddr contains
	// the address that the message was received from.
	ServeMessage(r *http.Request) ([]*http.Response, error)
}

Handler is the interface by which received SSDP messages are passed to handling code.

type HandlerFunc

type HandlerFunc func(r *http.Request) ([]*http.Response, error)

HandlerFunc is a function-to-Handler adapter.

func (HandlerFunc) ServeMessage

func (f HandlerFunc) ServeMessage(r *http.Request) ([]*http.Response, error)

Jump to

Keyboard shortcuts

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