package bot import "net/http" // SidecarHeader marks every request the live sidecar makes to its instance — // the WebSocket dial and all REST calls — so a hibernation-aware router // (activator.go) can tell sidecar traffic from member traffic. A co-spawned // sidecar's connections flow through its own instance's router (the box pins // its hosted names to loopback), and without the marker its keepalives would // read as member activity: the instance could never idle, and after a sleep // the reconnect loop would be a standing wake source. Marked requests are // served while the instance is awake but stamp no activity, and never wake a // sleeping one. // // The marker is deliberately spoofable-but-harmless: it only DOWNGRADES the // sender's own requests (no activity credit; 503 while the instance sleeps). // It cannot suppress other clients' activity stamps and cannot wake anything, // so an outsider sending it gains nothing. Provisioning (provision.go) stays // unmarked on purpose — claiming an invite is an operator action and should // behave like a person's request. const SidecarHeader = "X-Lchat-Sidecar" // markTransport stamps SidecarHeader on every request — the Runtime's HTTP // client uses it so no REST call site can forget the marker. It clones the // request first, per the RoundTripper contract. type markTransport struct{} func (markTransport) RoundTrip(req *http.Request) (*http.Response, error) { req = req.Clone(req.Context()) req.Header.Set(SidecarHeader, "1") return http.DefaultTransport.RoundTrip(req) }