aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.gitignore1
-rw-r--r--Makefile11
-rw-r--r--_www/rescached.js19
-rw-r--r--internal/cmd/www/main.go44
4 files changed, 65 insertions, 10 deletions
diff --git a/.gitignore b/.gitignore
index 503716c..5e36298 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,3 +1,4 @@
+/CHANGELOG.html
/README.html
/TODO
/_bin/darwin_amd64
diff --git a/Makefile b/Makefile
index a13040b..eb567c4 100644
--- a/Makefile
+++ b/Makefile
@@ -75,9 +75,9 @@ lint:
-shadow ./...
-golangci-lint run \
--presets bugs,metalinter,performance,unused \
+ --disable bodyclose \
--disable exhaustive \
--disable musttag \
- --disable bodyclose \
./...
-reuse --suppress-deprecation lint
@@ -222,3 +222,12 @@ build-linux-amd64: build
deploy-personal-server: build-linux-amd64
rsync --progress _bin/linux_amd64/rescached personal-server:~/bin/rescached
ssh personal-server "sudo rsync ~/bin/rescached /usr/bin/rescached; sudo systemctl restart rescached.service"
+
+
+#---- Development.
+
+## Run web server to test WUI.
+
+.PHONY: dev.www
+dev.www:
+ go run ./internal/cmd/www
diff --git a/_www/rescached.js b/_www/rescached.js
index cdfa4c3..a3fdbf5 100644
--- a/_www/rescached.js
+++ b/_www/rescached.js
@@ -39,21 +39,22 @@ function getRRTypeName(k) {
}
class Rescached {
+ static SERVER = "";
static nanoSeconds = 1000000000;
- static apiBlockd = "/api/block.d";
- static apiBlockdFetch = "/api/block.d/fetch";
+ static apiBlockd = Rescached.SERVER + "/api/block.d";
+ static apiBlockdFetch = Rescached.SERVER + "/api/block.d/fetch";
- static apiCaches = "/api/caches";
- static apiCachesSearch = "/api/caches/search";
+ static apiCaches = Rescached.SERVER + "/api/caches";
+ static apiCachesSearch = Rescached.SERVER + "/api/caches/search";
- static apiEnvironment = "/api/environment";
+ static apiEnvironment = Rescached.SERVER + "/api/environment";
- static apiHostsd = "/api/hosts.d";
- static apiHostsdRR = "/api/hosts.d/rr";
+ static apiHostsd = Rescached.SERVER + "/api/hosts.d";
+ static apiHostsdRR = Rescached.SERVER + "/api/hosts.d/rr";
- static apiZoned = "/api/zone.d";
- static apiZonedRR = "/api/zone.d/rr";
+ static apiZoned = Rescached.SERVER + "/api/zone.d";
+ static apiZonedRR = Rescached.SERVER + "/api/zone.d/rr";
constructor(server) {
this.blockd = {};
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)
+ }
+}