Control-plane requests follow the lease but take no slot and write no row

Implemented-By: OpenCode session (model recorded in docs/implementer-log.md)
This commit is contained in:
2026-09-25 17:44:00 -07:00
parent 3518e84dd7
commit 33fa61bedb
6 changed files with 251 additions and 15 deletions
+31
View File
@@ -0,0 +1,31 @@
package proxy
import (
"net/http"
"git.wntrmute.dev/kyle/crossbar/internal/config"
)
// isControlCall reports whether r is a control-plane call: a GET or HEAD on any allowed path, or a
// POST to exactly /tokenize or /v1/chat/completions/control. Everything else — in particular a chat
// completion on /v1/chat/completions — is not a control call. rest is the upstream path, not the
// query string.
func isControlCall(method, rest string) bool {
if method == http.MethodGet || method == http.MethodHead {
return true
}
return method == http.MethodPost && (rest == "/tokenize" || rest == "/v1/chat/completions/control")
}
// resolveModel returns the model for a request: the body's top-level "model" wins (already read by
// peekModel), else the ?model= query parameter, else the route's default_model. The result keys the
// lease and the limiter pair.
func resolveModel(model string, r *http.Request, routeCfg config.Route) string {
if model == "" {
model = r.URL.Query().Get("model")
}
if model == "" {
model = routeCfg.DefaultModel
}
return model
}