devf command - code.pfad.fr/devf

package devf provides livereload webserver for developers (inspired by [devd]). It attempts to do one thing and do it well: serve as a reverse proxy while injecting some JS to support livereloading.

devd

The livereload is triggered by a std-input newline or some OS-signals (usually provided by another tool).

Usage:

If <http-url-or-local-folders> contains `://`, it will be interpreted as a URL, otherwise as a local folder (multiple folders are supported: they will be looked up in order).

The flags are:

If a <sub-command> is provided, it will be launched in the background.

Example using inotifywait on linux

Local generation of the doc of this package (make doc):

Explanation (starting from the end of the command):

vanitydoc

http://localhost:8080

inotifywait

This example is somewhat contrived since [vanitydoc] now natively support livereloading (by importing the packages exposed by devf).

vanitydoc

Example using modd

[modd] will send a sighup to devf (which will trigger a reload) whenever a .gohtml file changes or the `server.is_running` file is written to (I usually do that in my main.go, when the server is ready to accept connections).

modd

To ensure that the livereload is injected on pages (especially error pages), make sure that the `Content-Type` header starts with `text/html`.

Advanced usage

If you need more control regarding the triggering of the reload, the reverse-proxying or of the local server, take a look at the [livereload] and [devfs] subpackages (feel free to take inspiration from how [vanitydoc] integrated them).

livereload

devfs

vanitydoc

License

European Union Public License 1.2 or later (EUPL-1.2+). Usage of the exported API of this library (or the CLI) is not considered "Derivative Works" (so you don't need to release your work under a EUPL-1.2 compatible license in such a case).

Files

local_fileserver.go

main.go

record.go

signal_linux.go

tls.go

Directories

devfs

package devfs exposes FS utilities (watch a directory for changes, fallback chain of FS).

livereload

package livereload handles Server-sent events and injection of the livereload script into upstream HTML pages.

Forge

https://codeberg.org/pfad.fr/devf

git clone