diff options
| author | Shulhan <ms@kilabit.info> | 2024-07-08 00:25:11 +0700 |
|---|---|---|
| committer | Shulhan <ms@kilabit.info> | 2024-07-15 00:36:07 +0700 |
| commit | e6c6a89ef014bef56d1078fcc622038d35ee2354 (patch) | |
| tree | 973072f71ba632ff6585362bc03d469e389d7b93 /internal | |
| parent | ac0c21615e9dc457995ab5bcb7161cf545887152 (diff) | |
| download | rescached-e6c6a89ef014bef56d1078fcc622038d35ee2354.tar.xz | |
internal/cmd/www: an HTTP server for testing web UI
The web user interface can be run using existing rescached server by
setting the SERVER value in class Rescached (_www/rescached.js).
Diffstat (limited to 'internal')
| -rw-r--r-- | internal/cmd/www/main.go | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/internal/cmd/www/main.go b/internal/cmd/www/main.go new file mode 100644 index 0000000..22b384b --- /dev/null +++ b/internal/cmd/www/main.go @@ -0,0 +1,44 @@ +// SPDX-FileCopyrightText: 2024 M. Shulhan <ms@kilabit.info> +// SPDX-License-Identifier: GPL-3.0-or-later + +// Package www provides an HTTP server that serve the _www directory for +// testing. +// The web user interface can be run using existing rescached server by +// setting the SERVER value in class Rescached (_www/rescached.js). +package main + +import ( + "flag" + "log" + + "git.sr.ht/~shulhan/ciigo" + "git.sr.ht/~shulhan/pakakeh.go/lib/memfs" +) + +func main() { + var flagAddress string + + flag.StringVar(&flagAddress, `address`, `127.0.0.1:6200`, `Listen address`) + + flag.Parse() + + var serveOpts = ciigo.ServeOptions{ + Mfs: &memfs.MemFS{ + Opts: &memfs.Options{ + Root: `./_www`, + TryDirect: true, + }, + }, + ConvertOptions: ciigo.ConvertOptions{ + Root: `./_www`, + HTMLTemplate: `./_www/doc/html.tmpl`, + }, + Address: flagAddress, + IsDevelopment: true, + } + + var err = ciigo.Serve(&serveOpts) + if err != nil { + log.Fatal(err) + } +} |
