forward

package
v0.1.9 Latest Latest
Warning

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

Go to latest
Published: Nov 17, 2026 License: Apache-2.0 Imports: 12 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package forward replays a webhook event verbatim, headers included, to a local handler.

Index

Constants

View Source
const (
	CauseTLS     = "tls"
	CauseTimeout = "timeout"
	CauseDown    = "down"
)

Why a forward got no answer.

Variables

This section is empty.

Functions

func Cause added in v0.1.3

func Cause(err error) string

Cause classifies a send error: an untrusted certificate, a slow handler, or one not running.

func Failure added in v0.1.3

func Failure(err error) string

Failure says why a forward got no answer, in words for whoever runs the handler. The Go transport error itself is not shown.

Types

type Forwarder

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

Forwarder POSTs webhook events to one local handler address.

func NewForwarder

func NewForwarder(addr string, skipTLSVerify bool) (*Forwarder, error)

NewForwarder builds a Forwarder for addr (scheme defaults to http). skipTLSVerify is refused off loopback.

func (*Forwarder) IsLoopback

func (f *Forwarder) IsLoopback() bool

IsLoopback reports whether the handler is on the local machine.

func (*Forwarder) IsPlaintextRemote

func (f *Forwarder) IsPlaintextRemote() bool

IsPlaintextRemote reports whether the handler is off-machine over plain http.

func (*Forwarder) IsUnverifiedTLS

func (f *Forwarder) IsUnverifiedTLS() bool

IsUnverifiedTLS reports whether the handler's certificate goes unchecked.

func (*Forwarder) Origin

func (f *Forwarder) Origin() string

Origin returns a stable identity for the handler; Target is for display.

func (*Forwarder) Send

func (f *Forwarder) Send(ctx context.Context, payload []byte, headers http.Header) (*Result, error)

Send POSTs payload with headers copied verbatim. A non-2xx is a Result; a transport failure is an error.

func (*Forwarder) Target

func (f *Forwarder) Target() string

Target returns the normalized handler URL.

type Result

type Result struct {
	StatusCode int
	Latency    time.Duration
	Body       []byte // bounded snippet, for a non-2xx diagnostic
}

Result is the outcome of forwarding one event.

func (*Result) OK

func (r *Result) OK() bool

OK reports whether the handler answered with a 2xx status.

type Unanswered added in v0.1.3

type Unanswered struct{ Cause string }

Unanswered is a forward that got no answer, kept as its cause so the cause survives a session writing it to disk and another reading it back.

func (*Unanswered) Error added in v0.1.3

func (u *Unanswered) Error() string

Jump to

Keyboard shortcuts

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