Fix routing to get rid of the awkward symlink dereferencing on build

This commit is contained in:
Jarno Rankinen 2024-03-07 23:46:59 +02:00
parent 64984d49d6
commit ef4d5c3bb9
5 changed files with 4 additions and 19 deletions

View File

@ -25,10 +25,6 @@ has been used.
### Building
- clone or download the repo
- `static/html/index.html` is symlinked to `coils` and `registers`
for development purposes, the symlinks need to be dereferenced before
building the binary on filesystems that support symlinks
- Replace symlinks with copies of the files or use e.g. `tar -h`
- Build for the correct architecture, e.g. for Linux 32-bit ARM (Rpi Zero W 1):
```
cd /path/to/repo

View File

@ -12,15 +12,4 @@ ARCH=${1:-"amd64"}
VERSION=$(grep -e 'version.*=' main.go | awk '{print $3}' | tr -d '"')
[[ ! -d "TMP" ]] && mkdir -p TMP
pushd TMP &> /dev/null || exit 1
tar --exclude ../TMP -ch ../* | tar xf -
#env GOOS=linux GOARCH=arm go build -o ../BUILD/enervent-ctrl-${VERSION}.linux-arm32 .
CGO_ENABLED=0 GOOS=linux GOARCH="$ARCH" go build -o "../BUILD/enervent-ctrl-${VERSION}.linux-$ARCH" .
rm -rf ./*
popd &> /dev/null || exit 1
CGO_ENABLED=0 GOOS=linux GOARCH="$ARCH" go build -o "../BUILD/enervent-ctrl-${VERSION}.linux-$ARCH" .

View File

@ -25,7 +25,7 @@ import (
var static embed.FS
var (
version = "0.1.1"
version = "0.1.2"
device pingvin.Pingvin
config Conf
usernamehash [32]byte
@ -64,6 +64,8 @@ func serve(cert, key *string) {
}
htmlroot := http.FileServer(http.FS(html))
http.HandleFunc("/", authHandler(htmlroot))
http.HandleFunc("/coils/", authHandler(http.StripPrefix("/coils/", htmlroot)))
http.HandleFunc("/registers/", authHandler(http.StripPrefix("/registers/", htmlroot)))
logdst, err := os.OpenFile(os.DevNull, os.O_WRONLY, os.ModeAppend)
if err != nil {
log.Fatal(err)

View File

@ -1 +0,0 @@
../index.html

View File

@ -1 +0,0 @@
../index.html