orchard
mirrorEvery site I host, in one repo, along with the Cloudflare Tunnel and Caddy that front them. It's all Go, Vite, and SQLite, and it runs on a desktop at home with nothing listening on an inbound port.
blogbuncaddycloudflare-tunneldockergogolanghomelabhtml-templatemonorepoself-hostedseosqlitestatic-sitetypstuptime-monitoringviteweb-analytics
1package main
2
3import (
4 "context"
5 "fmt"
6 "net/http"
7 "net/http/httptest"
8 "testing"
9)
10
11// The gateway keeps every prompt it forwards, so an incognito question that
12// leaves no history row here would still be readable there without this header.
13func TestAnIncognitoQuestionAsksTheGatewayNotToLog(t *testing.T) {
14 var seen string
15 srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
16 seen = r.Header.Get(incognitoHeader)
17 w.Header().Set("Content-Type", "application/json")
18 fmt.Fprint(w, `{"choices":[{"message":{"content":"hi"}}]}`)
19 }))
20 defer srv.Close()
21
22 l := NewLLM(srv.URL, "key")
23 if _, err := l.Complete(WithIncognito(context.Background()), "sys", "user", 8); err != nil {
24 t.Fatalf("complete: %v", err)
25 }
26 if seen != "1" {
27 t.Errorf("incognito header = %q, want 1", seen)
28 }
29
30 seen = ""
31 if _, err := l.Complete(context.Background(), "sys", "user", 8); err != nil {
32 t.Fatalf("complete: %v", err)
33 }
34 if seen != "" {
35 t.Errorf("an ordinary question sent the incognito header = %q", seen)
36 }
37}