livereload

package
v0.0.0-...-c1a3bfb Latest Latest
Warning

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

Go to latest
Published: Apr 27, 2020 License: MIT Imports: 10 Imported by: 0

Documentation

Overview

Package livereload allows HTML pages to be dynamically reloaded. It includes both the server and client implementations required.

Index

Constants

View Source
const (

	// EndpointPath is the path to the websocket endpoint
	EndpointPath = "/.devd.livereload"
	// ScriptPath is the path to the livereload JavaScript asset
	ScriptPath = "/.devd.livereload.js"
)

Variables

View Source
var Injector = inject.CopyInject{
	Within:      1024 * 30,
	ContentType: "text/html",
	Marker:      regexp.MustCompile(`<\/head>`),
	Payload:     []byte(`<script src="/.devd.livereload.js"></script>`),
}

Injector for the livereload script

Functions

This section is empty.

Types

type Reloader

type Reloader interface {
	Reload(paths []string)
	Watch(ch chan []string)
}

Reloader triggers a reload

type Server

type Server struct {
	sync.Mutex
	// contains filtered or unexported fields
}

Server implements a Livereload server

func NewServer

func NewServer(name string, logger termlog.Logger) *Server

NewServer createss a Server instance

func (*Server) Reload

func (s *Server) Reload(paths []string)

Reload signals to connected clients that a given resource should be reloaded.

func (*Server) ServeHTTP

func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request)

func (*Server) ServeScript

func (s *Server) ServeScript(rw http.ResponseWriter, req *http.Request)

ServeScript is a handler function that serves the livereload JavaScript file

func (*Server) Watch

func (s *Server) Watch(ch chan []string)

Watch montors a channel of lists of paths for reload requests

Jump to

Keyboard shortcuts

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