Skip to content

Commit 6943dbe

Browse files
committed
use a different method of ensuring you can build the binary without the frontend files
1 parent 753c81d commit 6943dbe

File tree

5 files changed

+13
-22
lines changed

5 files changed

+13
-22
lines changed

lib/httpapi/README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
The `chat/marker` file allows the agentapi binary to be built without
2+
populating the chat directory with real files. If the directory was empty,
3+
`go build` would fail.

lib/httpapi/chat/404.html

Lines changed: 0 additions & 11 deletions
This file was deleted.

lib/httpapi/chat/index.html

Lines changed: 0 additions & 10 deletions
This file was deleted.

lib/httpapi/chat/marker

Whitespace-only changes.

lib/httpapi/embed.go

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,20 @@ func FileServerWithIndexFallback() http.Handler {
2424
}
2525
chatFS := http.FS(subFS)
2626
fileServer := http.FileServer(chatFS)
27+
isChatDirEmpty := false
28+
if _, err := chatFS.Open("index.html"); err != nil {
29+
isChatDirEmpty = true
30+
}
2731

2832
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
33+
if isChatDirEmpty {
34+
http.Error(w,
35+
"Looks like you're running an agentapi build without the chat UI. To rebuild the binary with the UI files embedded, run `make build`.",
36+
http.StatusNotFound)
37+
return
38+
}
2939
path := r.URL.Path
3040
trimmedPath := strings.TrimPrefix(path, "/")
31-
fmt.Println("path", trimmedPath)
3241
if trimmedPath == "" {
3342
trimmedPath = "index.html"
3443
}

0 commit comments

Comments
 (0)