livereload

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Jun 6, 2023 License: GPL-3.0 Imports: 10 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func SingleLineRequestLogger

func SingleLineRequestLogger(lineWidthMax int) func(int, *http.Request, time.Duration)

func SlowResponseLogger

func SlowResponseLogger(timeout time.Duration) func(r *http.Request) chan<- struct{}

Types

type Handler

type Handler struct {
	Upstream http.Handler

	// LogRequest will be called after an upstream request has been handled,
	// for example SingleLineLogger.
	LogRequest func(statusCode int, r *http.Request, duration time.Duration)

	// LogSlowResponse should return a channel which will be closed when the
	// response headers for the corresponding request are sent.
	// See SlowResponseLogger for instance.
	LogSlowResponse func(r *http.Request) chan<- struct{}
	// contains filtered or unexported fields
}

func (*Handler) ForwardMessages

func (h *Handler) ForwardMessages(messages <-chan string, initialRefreshDelay, minRefreshInterval time.Duration)

ForwardMessages forwards messages to the webpage, to trigger a reload. The method returns when messages is closed. If initialRefreshDelay is set (5ms for instance), it will delay the first message forwarding (in case of initial message burst). If minRefreshInterval is set (1s for instance), it will delay further message forwarding. (in case of repeated messages).

func (*Handler) ServeHTTP

func (h *Handler) ServeHTTP(w http.ResponseWriter, r *http.Request)

Jump to

Keyboard shortcuts

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