Files
threshold/internal/daemon/controller/handler_noui.go
shadowdaoandClaude Sonnet 5.5 962d708fdd Rename Go module paths to repo.anhonesthost.net/CyberCoveLLC/threshold
Rename root, api and sdk module paths (imports, go.mod, go_package,
ldflags, build scripts, buf configs) and regenerate protobuf/gateway
code with the project's pinned toolchain. Wire identifiers unchanged.
api gets a local replace for sdk; root/api/sdk require v0.1.0.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-12 10:33:41 -07:00

39 lines
1.0 KiB
Go

// Copyright IBM Corp. 2020, 2026
// SPDX-License-Identifier: BUSL-1.1
package controller
import (
"context"
"net/http"
"path/filepath"
"repo.anhonesthost.net/CyberCoveLLC/threshold/internal/event"
)
func devUiPassthroughHandler(uiPassthroughDir string) http.Handler {
const op = "controller.devPassthroughHandler"
ctx := context.TODO()
// Panic may not be ideal but this is never a production call and it'll
// panic on startup. We could also just change the function to return
// an error.
abs, err := filepath.Abs(uiPassthroughDir)
if err != nil {
panic(err)
}
event.WriteSysEvent(ctx, op, "serving passthrough files at /", "path", abs)
fs := http.FileServer(http.Dir(abs))
prefixHandler := http.StripPrefix("/", fs)
return prefixHandler
}
var handleUi = func(c *Controller) http.Handler {
if c.conf.RawConfig.DevUiPassthroughDir != "" {
return devUiPassthroughHandler(c.conf.RawConfig.DevUiPassthroughDir)
}
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
w.WriteHeader(http.StatusNotFound)
})
}