mirror of
https://github.com/jwetzell/showbridge-go.git
synced 2026-08-12 01:43:40 +00:00
Compare commits
4 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 86902714a2 | |||
| 6be2fd5410 | |||
| ac55923a27 | |||
| 0296afc2a3 |
@@ -21,7 +21,7 @@ jobs:
|
||||
with:
|
||||
fetch-depth: 0
|
||||
- name: set environment variables
|
||||
run: echo "SHOWBRIDGE_VERSION=${GITHUB_REF_NAME}" >> $GITHUB_ENV
|
||||
run: echo "SHOWBRIDGE_VERSION=${GITHUB_SHA::7}" >> $GITHUB_ENV
|
||||
- name: clean tag
|
||||
if: startsWith(github.ref, 'refs/tags/v')
|
||||
run: echo "SHOWBRIDGE_VERSION=${SHOWBRIDGE_VERSION#v}" >> $GITHUB_ENV
|
||||
@@ -37,6 +37,37 @@ jobs:
|
||||
with:
|
||||
draft: true
|
||||
generate_release_notes: true
|
||||
build_webui:
|
||||
runs-on: ubuntu-latest
|
||||
needs: setup_release
|
||||
env:
|
||||
SHOWBRIDGE_VERSION: ${{ needs.setup_release.outputs.version }}
|
||||
SHORT_COMMIT: ${{ needs.setup_release.outputs.short_commit }}
|
||||
steps:
|
||||
- name: Check out repository
|
||||
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
|
||||
with:
|
||||
repository: jwetzell/showbridge-webui
|
||||
ref: main
|
||||
|
||||
- name: Set up Node.js
|
||||
uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0
|
||||
with:
|
||||
node-version-file: ".nvmrc"
|
||||
cache: "npm"
|
||||
cache-dependency-path: "package-lock.json"
|
||||
|
||||
- name: Install Node.js dependencies
|
||||
run: npm ci
|
||||
|
||||
- run: npm run build -- --base-href=/ui/
|
||||
|
||||
- name: upload webui artifacts
|
||||
uses: actions/upload-artifact@v7
|
||||
with:
|
||||
name: showbridge-webui
|
||||
path: dist/webui/
|
||||
|
||||
linux_amd64:
|
||||
runs-on: ubuntu-24.04
|
||||
needs: setup_release
|
||||
@@ -54,6 +85,11 @@ jobs:
|
||||
go-version-file: "go.mod"
|
||||
- name: install alsa lib
|
||||
run: sudo apt-get install -y libasound2-dev
|
||||
- name: get webui artifacts
|
||||
uses: actions/download-artifact@v8
|
||||
with:
|
||||
name: showbridge-webui
|
||||
path: internal/api/webui/
|
||||
- name: build
|
||||
run: |
|
||||
CGO_ENABLED=1 go build -o showbridge -ldflags="-s -w -X main.version=${SHOWBRIDGE_VERSION}-${SHORT_COMMIT}" ./cmd/showbridge
|
||||
@@ -88,9 +124,14 @@ jobs:
|
||||
go-version-file: "go.mod"
|
||||
- name: install alsa lib
|
||||
run: sudo apt-get install -y libasound2-dev
|
||||
- name: get webui artifacts
|
||||
uses: actions/download-artifact@v8
|
||||
with:
|
||||
name: showbridge-webui
|
||||
path: internal/api/webui/
|
||||
- name: build
|
||||
run: |
|
||||
CGO_ENABLED=1 go build -o showbridge -ldflags="-s -w -X main.version=${SHOWBRIDGE_VERSION}-${SHORT_COMMIT}" ./cmd/showbridge
|
||||
CGO_ENABLED=1 go build -o showbridge -ldflags="-s -w -X main.version=${SHOWBRIDGE_VERSION}-${SHORT_COMMIT}" -tags=showbridge_webui ./cmd/showbridge
|
||||
tar -czf showbridge_${SHOWBRIDGE_VERSION}_linux-arm64.tar.gz showbridge
|
||||
- name: upload linux artifacts
|
||||
uses: actions/upload-artifact@v7
|
||||
@@ -124,13 +165,18 @@ jobs:
|
||||
uses: mlugg/setup-zig@v2
|
||||
with:
|
||||
version: 0.16.0
|
||||
- name: get webui artifacts
|
||||
uses: actions/download-artifact@v8
|
||||
with:
|
||||
name: showbridge-webui
|
||||
path: internal/api/webui/
|
||||
- name: build amd64
|
||||
run: |
|
||||
CGO_ENABLED=1 GOOS=windows GOARCH=amd64 CC="zig cc -target x86_64-windows-gnu" CXX="zig c++ -target x86_64-windows-gnu" go build -o showbridge.exe -ldflags="-s -w -X main.version=${SHOWBRIDGE_VERSION}-${SHORT_COMMIT}" ./cmd/showbridge
|
||||
CGO_ENABLED=1 GOOS=windows GOARCH=amd64 CC="zig cc -target x86_64-windows-gnu" CXX="zig c++ -target x86_64-windows-gnu" go build -o showbridge.exe -ldflags="-s -w -X main.version=${SHOWBRIDGE_VERSION}-${SHORT_COMMIT}" -tags=showbridge_webui ./cmd/showbridge
|
||||
zip showbridge_${SHOWBRIDGE_VERSION}_windows-amd64.zip showbridge.exe
|
||||
- name: build arm64
|
||||
run: |
|
||||
CGO_ENABLED=1 GOOS=windows GOARCH=arm64 CC="zig cc -target aarch64-windows-gnu" CXX="zig c++ -target aarch64-windows-gnu" go build -o showbridge.exe -ldflags="-s -w -X main.version=${SHOWBRIDGE_VERSION}-${SHORT_COMMIT}" ./cmd/showbridge
|
||||
CGO_ENABLED=1 GOOS=windows GOARCH=arm64 CC="zig cc -target aarch64-windows-gnu" CXX="zig c++ -target aarch64-windows-gnu" go build -o showbridge.exe -ldflags="-s -w -X main.version=${SHOWBRIDGE_VERSION}-${SHORT_COMMIT}" -tags=showbridge_webui ./cmd/showbridge
|
||||
zip showbridge_${SHOWBRIDGE_VERSION}_windows-arm64.zip showbridge.exe
|
||||
- name: upload windows artifacts
|
||||
uses: actions/upload-artifact@v7
|
||||
@@ -160,9 +206,14 @@ jobs:
|
||||
uses: actions/setup-go@v7
|
||||
with:
|
||||
go-version-file: "go.mod"
|
||||
- name: get webui artifacts
|
||||
uses: actions/download-artifact@v8
|
||||
with:
|
||||
name: showbridge-webui
|
||||
path: internal/api/webui/
|
||||
- name: build
|
||||
run: |
|
||||
CGO_ENABLED=1 GOOS=darwin GOARCH=arm64 go build -o showbridge -ldflags="-s -w -X main.version=${SHOWBRIDGE_VERSION}-${SHORT_COMMIT}" ./cmd/showbridge
|
||||
CGO_ENABLED=1 GOOS=darwin GOARCH=arm64 go build -o showbridge -ldflags="-s -w -X main.version=${SHOWBRIDGE_VERSION}-${SHORT_COMMIT}" -tags=showbridge_webui ./cmd/showbridge
|
||||
tar -czf showbridge_${SHOWBRIDGE_VERSION}_macOS-arm64.tar.gz showbridge
|
||||
- name: upload macos artifacts
|
||||
uses: actions/upload-artifact@v7
|
||||
@@ -179,7 +230,7 @@ jobs:
|
||||
files: showbridge_*.tar.gz
|
||||
macos_amd64:
|
||||
runs-on: macos-26-intel
|
||||
needs: setup_release
|
||||
needs: [setup_release, build_webui]
|
||||
env:
|
||||
SHOWBRIDGE_VERSION: ${{ needs.setup_release.outputs.version }}
|
||||
SHORT_COMMIT: ${{ needs.setup_release.outputs.short_commit }}
|
||||
@@ -192,9 +243,14 @@ jobs:
|
||||
uses: actions/setup-go@v7
|
||||
with:
|
||||
go-version-file: "go.mod"
|
||||
- name: get webui artifacts
|
||||
uses: actions/download-artifact@v8
|
||||
with:
|
||||
name: showbridge-webui
|
||||
path: internal/api/webui/
|
||||
- name: build
|
||||
run: |
|
||||
CGO_ENABLED=1 GOOS=darwin GOARCH=amd64 go build -o showbridge -ldflags="-s -w -X main.version=${SHOWBRIDGE_VERSION}-${SHORT_COMMIT}" ./cmd/showbridge
|
||||
CGO_ENABLED=1 GOOS=darwin GOARCH=amd64 go build -o showbridge -ldflags="-s -w -X main.version=${SHOWBRIDGE_VERSION}-${SHORT_COMMIT}" -tags=showbridge_webui ./cmd/showbridge
|
||||
tar -czf showbridge_${SHOWBRIDGE_VERSION}_macOS-amd64.tar.gz showbridge
|
||||
- name: upload macos artifacts
|
||||
uses: actions/upload-artifact@v7
|
||||
|
||||
+3
-7
@@ -13,15 +13,11 @@ modules:
|
||||
port: 8000
|
||||
routes:
|
||||
- input: http
|
||||
id: http-to-osc
|
||||
processors:
|
||||
- id: create-osc
|
||||
type: osc.message.create
|
||||
- type: osc.message.create
|
||||
params:
|
||||
address: "{{.Payload.URL.Path}}"
|
||||
- id: encode-osc
|
||||
type: osc.message.encode
|
||||
- id: output-osc
|
||||
type: module.output
|
||||
- type: osc.message.encode
|
||||
- type: module.output
|
||||
params:
|
||||
module: udp
|
||||
|
||||
@@ -16,13 +16,13 @@ require (
|
||||
github.com/jwetzell/psn-go v0.3.0
|
||||
github.com/nats-io/nats-server/v2 v2.14.4
|
||||
github.com/nats-io/nats.go v1.52.0
|
||||
github.com/redis/go-redis/v9 v9.22.0
|
||||
github.com/redis/go-redis/v9 v9.21.0
|
||||
github.com/urfave/cli/v3 v3.10.1
|
||||
gitlab.com/gomidi/midi/v2 v2.3.24
|
||||
go.bug.st/serial v1.8.0
|
||||
golang.org/x/time v0.15.0
|
||||
modernc.org/quickjs v0.23.0
|
||||
modernc.org/sqlite v1.56.0
|
||||
modernc.org/quickjs v0.22.0
|
||||
modernc.org/sqlite v1.55.0
|
||||
sigs.k8s.io/yaml v1.6.0
|
||||
)
|
||||
|
||||
@@ -42,7 +42,7 @@ require (
|
||||
github.com/ianlancetaylor/demangle v0.0.0-20260505044615-1ff4bf46051f // indirect
|
||||
github.com/icholy/digest v1.1.0 // indirect
|
||||
github.com/klauspost/compress v1.19.0 // indirect
|
||||
github.com/mattn/go-isatty v0.0.24 // indirect
|
||||
github.com/mattn/go-isatty v0.0.22 // indirect
|
||||
github.com/minio/highwayhash v1.0.4 // indirect
|
||||
github.com/nats-io/jwt/v2 v2.8.2 // indirect
|
||||
github.com/nats-io/nkeys v0.4.16 // indirect
|
||||
@@ -69,8 +69,8 @@ require (
|
||||
golang.org/x/sys v0.47.0 // indirect
|
||||
google.golang.org/protobuf v1.36.11 // indirect
|
||||
gopkg.in/hraban/opus.v2 v2.0.0-20230925203106-0188a62cb302 // indirect
|
||||
modernc.org/libc v1.74.4 // indirect
|
||||
modernc.org/libquickjs v0.13.1 // indirect
|
||||
modernc.org/libc v1.74.3 // indirect
|
||||
modernc.org/libquickjs v0.12.10 // indirect
|
||||
modernc.org/mathutil v1.7.1 // indirect
|
||||
modernc.org/memory v1.11.0 // indirect
|
||||
)
|
||||
|
||||
@@ -40,8 +40,8 @@ github.com/google/go-tpm v0.9.8 h1:slArAR9Ft+1ybZu0lBwpSmpwhRXaa85hWtMinMyRAWo=
|
||||
github.com/google/go-tpm v0.9.8/go.mod h1:h9jEsEECg7gtLis0upRBQU+GhYVH6jMjrFxI8u6bVUY=
|
||||
github.com/google/jsonschema-go v0.4.3 h1:/DBOLZTfDow7pe2GmaJNhltueGTtDKICi8V8p+DQPd0=
|
||||
github.com/google/jsonschema-go v0.4.3/go.mod h1:r5quNTdLOYEz95Ru18zA0ydNbBuYoo9tgaYcxEYhJVE=
|
||||
github.com/google/pprof v0.0.0-20260802141513-ef3492d7dac3 h1:LMLX+LgTNWpfvCBdFebv6EsYotImrt/Ppc5cXIriCSo=
|
||||
github.com/google/pprof v0.0.0-20260802141513-ef3492d7dac3/go.mod h1:jl5iWTm0/hd5PjEYEOuwAJ57L/CibdZfrqZ5XA5GrCk=
|
||||
github.com/google/pprof v0.0.0-20250317173921-a4b03ec1a45e h1:ijClszYn+mADRFY17kjQEVQ1XRhq2/JR1M3sGqeJoxs=
|
||||
github.com/google/pprof v0.0.0-20250317173921-a4b03ec1a45e/go.mod h1:boTsfXsheKC2y+lKOCMpSfarhxDeIzfZG1jqGcPl3cA=
|
||||
github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0=
|
||||
github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
|
||||
github.com/gorilla/websocket v1.5.3 h1:saDtZ6Pbx/0u+bgYQ3q96pZgCzfhKXGPqt7kZ72aNNg=
|
||||
@@ -68,8 +68,8 @@ github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE=
|
||||
github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk=
|
||||
github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
|
||||
github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
|
||||
github.com/mattn/go-isatty v0.0.24 h1:tGZZoVgT/KiqK1c8ocVLeDS8BSWMRd47J3Lbz7vsReI=
|
||||
github.com/mattn/go-isatty v0.0.24/go.mod h1:nMCL3Zebbrt45jsMDgnfIwz6ydEQApk5oEI3HqDio6A=
|
||||
github.com/mattn/go-isatty v0.0.22 h1:j8l17JJ9i6VGPUFUYoTUKPSgKe/83EYU2zBC7YNKMw4=
|
||||
github.com/mattn/go-isatty v0.0.22/go.mod h1:ZXfXG4SQHsB/w3ZeOYbR0PrPwLy+n6xiMrJlRFqopa4=
|
||||
github.com/minio/highwayhash v1.0.4 h1:asJizugGgchQod2ja9NJlGOWq4s7KsAWr5XUc9Clgl4=
|
||||
github.com/minio/highwayhash v1.0.4/go.mod h1:GGYsuwP/fPD6Y9hMiXuapVvlIUEhFhMTh0rxU3ik1LQ=
|
||||
github.com/nats-io/jwt/v2 v2.8.2 h1:XXRgB60MSTnqsRwejQurVDs/hcv2dkt+86GjI+I/bMc=
|
||||
@@ -98,8 +98,8 @@ github.com/pion/transport/v4 v4.0.1 h1:sdROELU6BZ63Ab7FrOLn13M6YdJLY20wldXW2Cu2k
|
||||
github.com/pion/transport/v4 v4.0.1/go.mod h1:nEuEA4AD5lPdcIegQDpVLgNoDGreqM/YqmEx3ovP4jM=
|
||||
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
|
||||
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
||||
github.com/redis/go-redis/v9 v9.22.0 h1:laDvpYXTJtZLloinw1fA5Kqd6HAEH2XKxOkG/PDq2F0=
|
||||
github.com/redis/go-redis/v9 v9.22.0/go.mod h1:y2g0Wj8rQvuK0ELM+oxSudcLtC09JScs98I/X9gRWY4=
|
||||
github.com/redis/go-redis/v9 v9.21.0 h1:FPBE4hhbAke+TLmcY3WkpbDffJEomdqPn3HYiqAtL9E=
|
||||
github.com/redis/go-redis/v9 v9.21.0/go.mod h1:v/M13XI1PVCDcm01VtPFOADfZtHf8YW3baQf57KlIkA=
|
||||
github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec h1:W09IVJc94icq4NjY3clb7Lk8O1qJ8BdBEF8z0ibU0rE=
|
||||
github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec/go.mod h1:qqbHyh8v60DhA7CoWK5oRCqLrMHRGoxYCSS9EjAz6Eo=
|
||||
github.com/rogpeppe/go-internal v1.14.1 h1:UQB4HGPB6osV0SQTLymcB4TgvyWu6ZyliaW0tI/otEQ=
|
||||
@@ -163,26 +163,26 @@ modernc.org/fileutil v1.4.0 h1:j6ZzNTftVS054gi281TyLjHPp6CPHr2KCxEXjEbD6SM=
|
||||
modernc.org/fileutil v1.4.0/go.mod h1:EqdKFDxiByqxLk8ozOxObDSfcVOv/54xDs/DUHdvCUU=
|
||||
modernc.org/gc/v2 v2.6.5 h1:nyqdV8q46KvTpZlsw66kWqwXRHdjIlJOhG6kxiV/9xI=
|
||||
modernc.org/gc/v2 v2.6.5/go.mod h1:YgIahr1ypgfe7chRuJi2gD7DBQiKSLMPgBQe9oIiito=
|
||||
modernc.org/gc/v3 v3.1.5 h1:21ldfPfRYE31Tb7B3mwAK8gy1AxP4+dKjrOQPfqakoc=
|
||||
modernc.org/gc/v3 v3.1.5/go.mod h1:HFK/6AGESC7Ex+EZJhJ2Gni6cTaYpSMmU/cT9RmlfYY=
|
||||
modernc.org/gc/v3 v3.1.4 h1:2g65LGVSmFQrXeITAw97x7hCRvZFcyE1uDP+7Vng7JI=
|
||||
modernc.org/gc/v3 v3.1.4/go.mod h1:HFK/6AGESC7Ex+EZJhJ2Gni6cTaYpSMmU/cT9RmlfYY=
|
||||
modernc.org/goabi0 v0.2.0 h1:HvEowk7LxcPd0eq6mVOAEMai46V+i7Jrj13t4AzuNks=
|
||||
modernc.org/goabi0 v0.2.0/go.mod h1:CEFRnnJhKvWT1c1JTI3Avm+tgOWbkOu5oPA8eH8LnMI=
|
||||
modernc.org/libc v1.74.4 h1:fX1Omw4o2/1C2iRkkIsrQTasJQldLhRmuPreXLoWs9k=
|
||||
modernc.org/libc v1.74.4/go.mod h1:eeQAS9W3sZeKYMFubydxJpII9ybHWshk+7or7bLG9co=
|
||||
modernc.org/libquickjs v0.13.1 h1:uCb9AYyEyL1JS2dnKtLZKWH/vDb36cx1Mr1SIdbzb8A=
|
||||
modernc.org/libquickjs v0.13.1/go.mod h1:tCEsA1Zda1+C5JagFIJGqjYZOxDPFOUYjK3dGhEeq0g=
|
||||
modernc.org/libc v1.74.3 h1:a4J+Z8aVaxPyjyxRAdJzw246PqpcFGvVPnfT/AuM5Ws=
|
||||
modernc.org/libc v1.74.3/go.mod h1:4H7h/MJ8wnjL8RAbp9v3OXgnk22X7MouHIhDbvP3gj4=
|
||||
modernc.org/libquickjs v0.12.10 h1:nhfXth/BywJmx3Flid/r7iQYdPzc/+B4LDigA9YIKtQ=
|
||||
modernc.org/libquickjs v0.12.10/go.mod h1:UedJnNW5BS4PbItZnk0Zg4tUI7m0ImmmtJAI3yqoF30=
|
||||
modernc.org/mathutil v1.7.1 h1:GCZVGXdaN8gTqB1Mf/usp1Y/hSqgI2vAGGP4jZMCxOU=
|
||||
modernc.org/mathutil v1.7.1/go.mod h1:4p5IwJITfppl0G4sUEDtCr4DthTaT47/N3aT6MhfgJg=
|
||||
modernc.org/memory v1.11.0 h1:o4QC8aMQzmcwCK3t3Ux/ZHmwFPzE6hf2Y5LbkRs+hbI=
|
||||
modernc.org/memory v1.11.0/go.mod h1:/JP4VbVC+K5sU2wZi9bHoq2MAkCnrt2r98UGeSK7Mjw=
|
||||
modernc.org/opt v0.2.0 h1:tGyef5ApycA7FSEOMraay9SaTk5zmbx7Tu+cJs4QKZg=
|
||||
modernc.org/opt v0.2.0/go.mod h1:03fq9lsNfvkYSfxrfUhZCWPk1lm4cq4N+Bh//bEtgns=
|
||||
modernc.org/quickjs v0.23.0 h1:k+px+rFrMqHm2LPMvrd+vCR+8m6eogiTkROz+YJHkj8=
|
||||
modernc.org/quickjs v0.23.0/go.mod h1:bFvjVk4JGlbqLYXVFt72YvwdnHbwtNIE9nQ+eh4fdi0=
|
||||
modernc.org/quickjs v0.22.0 h1:4YhaspgX4Nc+YN84ZTQdlVMnQCY7M5GloF+D+UvEg7I=
|
||||
modernc.org/quickjs v0.22.0/go.mod h1:kRfDSgneM1WAd/niu2O3tqpTy+HB6+25DmTNKr+DqDA=
|
||||
modernc.org/sortutil v1.2.1 h1:+xyoGf15mM3NMlPDnFqrteY07klSFxLElE2PVuWIJ7w=
|
||||
modernc.org/sortutil v1.2.1/go.mod h1:7ZI3a3REbai7gzCLcotuw9AC4VZVpYMjDzETGsSMqJE=
|
||||
modernc.org/sqlite v1.56.0 h1:/D8e2RfFqoy/Zc6PuC76U28zFwmI/sYx1Kjm4yEn9e0=
|
||||
modernc.org/sqlite v1.56.0/go.mod h1:yCJ2cmAaIkHQ25oXWrF8H4O1lIfPYPR26yCEDj2P3pQ=
|
||||
modernc.org/sqlite v1.55.0 h1:hIFh0MCH0rGinQ/4KYb5/UbCkRkb+UP+OkLCVWa5MTM=
|
||||
modernc.org/sqlite v1.55.0/go.mod h1:4ntCLuNmnH8+GNqjka1wNg7KJd5/Hi5FYp8K+XQ7GZw=
|
||||
modernc.org/strutil v1.2.1 h1:UneZBkQA+DX2Rp35KcM69cSsNES9ly8mQWD71HKlOA0=
|
||||
modernc.org/strutil v1.2.1/go.mod h1:EHkiggD70koQxjVdSBM3JKM7k6L0FbGE5eymy9i3B9A=
|
||||
modernc.org/token v1.1.0 h1:Xl7Ap9dKaEs5kLoOQeQmPWevfnk/DM5qcLcYlA8ys6Y=
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
webui/
|
||||
@@ -48,6 +48,8 @@ func (as *ApiServer) Start(config config.ApiConfig) {
|
||||
mux.HandleFunc("/schema/routes.schema.json", handleRoutesSchema)
|
||||
mux.HandleFunc("/schema/modules.schema.json", handleModulesSchema)
|
||||
mux.HandleFunc("/schema/processors.schema.json", handleProcessorsSchema)
|
||||
mux.HandleFunc("/ui", handleWebUI)
|
||||
mux.HandleFunc("/ui/", handleWebUI)
|
||||
|
||||
as.serverMu.Lock()
|
||||
defer as.serverMu.Unlock()
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
//go:build !showbridge_webui
|
||||
|
||||
package api
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
)
|
||||
|
||||
func handleWebUI(w http.ResponseWriter, req *http.Request) {
|
||||
|
||||
http.Error(w, "Web UI is not enabled", http.StatusNotImplemented)
|
||||
}
|
||||
@@ -0,0 +1,73 @@
|
||||
//go:build showbridge_webui
|
||||
|
||||
package api
|
||||
|
||||
import (
|
||||
"embed"
|
||||
"errors"
|
||||
"io/fs"
|
||||
"net/http"
|
||||
"path"
|
||||
"strings"
|
||||
|
||||
_ "embed"
|
||||
)
|
||||
|
||||
//go:embed webui
|
||||
var webUIFS embed.FS
|
||||
|
||||
var fsPrefix = "webui/browser"
|
||||
|
||||
var index = path.Join(fsPrefix, "index.html")
|
||||
|
||||
func handleWebUI(w http.ResponseWriter, req *http.Request) {
|
||||
requestedPath := strings.TrimLeft(req.URL.Path, "/ui")
|
||||
switch req.Method {
|
||||
case http.MethodGet:
|
||||
var pathToLoad string
|
||||
stat, err := fs.Stat(webUIFS, path.Join(fsPrefix, requestedPath))
|
||||
if err != nil {
|
||||
if errors.Is(err, fs.ErrNotExist) {
|
||||
pathToLoad = index
|
||||
} else {
|
||||
http.Error(w, "Internal server error", http.StatusInternalServerError)
|
||||
return
|
||||
}
|
||||
}
|
||||
if stat != nil {
|
||||
if stat.IsDir() {
|
||||
pathToLoad = index
|
||||
} else {
|
||||
pathToLoad = path.Join(fsPrefix, requestedPath)
|
||||
}
|
||||
}
|
||||
file, err := webUIFS.ReadFile(pathToLoad)
|
||||
if err != nil {
|
||||
http.Error(w, "Internal server error", http.StatusInternalServerError)
|
||||
return
|
||||
}
|
||||
w.Header().Set("Access-Control-Allow-Origin", "*")
|
||||
|
||||
switch path.Ext(pathToLoad) {
|
||||
case ".js":
|
||||
w.Header().Set("Content-Type", "application/javascript")
|
||||
case ".css":
|
||||
w.Header().Set("Content-Type", "text/css")
|
||||
case ".html":
|
||||
w.Header().Set("Content-Type", "text/html")
|
||||
case ".ico":
|
||||
w.Header().Set("Content-Type", "image/x-icon")
|
||||
}
|
||||
w.Write(file)
|
||||
return
|
||||
|
||||
case http.MethodOptions:
|
||||
w.Header().Set("Access-Control-Allow-Origin", "*")
|
||||
w.Header().Set("Access-Control-Allow-Methods", "GET, OPTIONS")
|
||||
w.Header().Set("Access-Control-Allow-Headers", "Content-Type")
|
||||
w.WriteHeader(http.StatusOK)
|
||||
default:
|
||||
w.Header().Set("Access-Control-Allow-Origin", "*")
|
||||
w.WriteHeader(http.StatusMethodNotAllowed)
|
||||
}
|
||||
}
|
||||
@@ -1,7 +1,6 @@
|
||||
package config
|
||||
|
||||
type ProcessorConfig struct {
|
||||
Id string `json:"id"`
|
||||
Type string `json:"type"`
|
||||
Params Params `json:"params,omitempty"`
|
||||
}
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package config
|
||||
|
||||
type RouteConfig struct {
|
||||
Id string `json:"id"`
|
||||
Input string `json:"input"`
|
||||
Processors []ProcessorConfig `json:"processors"`
|
||||
}
|
||||
|
||||
@@ -148,13 +148,13 @@ func (mc *MQTTClient) Start(ctx context.Context, inputHandler common.InputHandle
|
||||
mc.client = mqtt.NewClient(opts)
|
||||
|
||||
token := mc.client.Connect()
|
||||
mc.clientMu.Unlock()
|
||||
|
||||
token.Wait()
|
||||
err := token.Error()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
mc.clientMu.Unlock()
|
||||
|
||||
<-mc.ctx.Done()
|
||||
mc.logger.Debug("done")
|
||||
|
||||
@@ -10,7 +10,6 @@ import (
|
||||
)
|
||||
|
||||
type Route struct {
|
||||
id string
|
||||
input string
|
||||
processors []processor.Processor
|
||||
}
|
||||
@@ -33,11 +32,7 @@ func NewRoute(config config.RouteConfig) (*Route, error) {
|
||||
}
|
||||
}
|
||||
|
||||
return &Route{id: config.Id, input: config.Input, processors: processors}, nil
|
||||
}
|
||||
|
||||
func (r *Route) Id() string {
|
||||
return r.id
|
||||
return &Route{input: config.Input, processors: processors}, nil
|
||||
}
|
||||
|
||||
func (r *Route) Input() string {
|
||||
|
||||
@@ -24,15 +24,11 @@ func GetProcessorsSchema() *jsonschema.Schema {
|
||||
ID: proc.Type,
|
||||
Type: "object",
|
||||
Properties: map[string]*jsonschema.Schema{
|
||||
"id": {
|
||||
Type: "string",
|
||||
MinLength: new(1),
|
||||
},
|
||||
"type": {
|
||||
Const: jsonschema.Ptr[any](proc.Type),
|
||||
},
|
||||
},
|
||||
Required: []string{"id", "type"},
|
||||
Required: []string{"type"},
|
||||
AdditionalProperties: &jsonschema.Schema{Not: &jsonschema.Schema{}},
|
||||
}
|
||||
if proc.Title != "" {
|
||||
|
||||
@@ -15,10 +15,6 @@ var RoutesConfigSchema = jsonschema.Schema{
|
||||
Items: &jsonschema.Schema{
|
||||
Type: "object",
|
||||
Properties: map[string]*jsonschema.Schema{
|
||||
"id": {
|
||||
Type: "string",
|
||||
MinLength: new(1),
|
||||
},
|
||||
"input": {
|
||||
Type: "string",
|
||||
MinLength: new(1),
|
||||
@@ -27,7 +23,7 @@ var RoutesConfigSchema = jsonschema.Schema{
|
||||
Ref: "https://showbridge.io/processors.schema.json",
|
||||
},
|
||||
},
|
||||
Required: []string{"id", "input"},
|
||||
Required: []string{"input"},
|
||||
AdditionalProperties: &jsonschema.Schema{Not: &jsonschema.Schema{}},
|
||||
},
|
||||
Default: json.RawMessage(`[]`),
|
||||
|
||||
Reference in New Issue
Block a user