Forward the request target a caller actually named

An adapted net/http handler was handed a request with an empty RequestURI, so
anything that routes or logs on the target saw "/" and answered for a path
nobody asked for. The pin carries the fix.

The registrations in the tests say which method they answer with, the same as
the ones they exercise.

Co-authored-by: Hanzo Dev <[email protected]>
This commit is contained in:
2026-09-17 06:00:54 -07:00
co-authored by Hanzo Dev
parent a37196d301
commit 0e01a3c442
5 changed files with 9 additions and 6 deletions
+2 -2
View File
@@ -55,7 +55,7 @@ func TestConnMemory(t *testing.T) {
// lives under BASE_API_PREFIX (default /v1); we don't need to
// mount the full plugin set to measure the fasthttp accept-loop
// per-conn budget.
app.Get("/healthz", func(c *zip.Ctx) error {
app.Raw(http.MethodGet, "/healthz", func(c *zip.Ctx) error {
return c.JSON(http.StatusOK, map[string]any{
"status": "ok",
"service": "base",
@@ -65,7 +65,7 @@ func TestConnMemory(t *testing.T) {
ctx, cancel := context.WithCancel(context.Background())
defer cancel()
var holding atomic.Int64
app.Get("/hold", func(c *zip.Ctx) error {
app.Raw(http.MethodGet, "/hold", func(c *zip.Ctx) error {
holding.Add(1)
defer holding.Add(-1)
<-ctx.Done()
+1 -1
View File
@@ -42,7 +42,7 @@ require (
github.com/spf13/cobra v1.10.2
github.com/valyala/fasthttp v1.74.0
github.com/zap-proto/http v0.3.9
github.com/zap-proto/zip v1.37.1
github.com/zap-proto/zip v1.37.3
go.starlark.net v0.0.0-20260908191801-89a6a09411d5
golang.org/x/crypto v0.57.0
golang.org/x/image v0.46.0
+2
View File
@@ -453,6 +453,8 @@ github.com/zap-proto/zip v1.36.48 h1:H3iHBP4wBU8A17OgpWSnDLQmLBYQQrOSY2O7/Hr3BZ0
github.com/zap-proto/zip v1.36.48/go.mod h1:sjlwTZhK8yLnjLWreVhK9VZrf2M/doKtEaqgZzCx+I0=
github.com/zap-proto/zip v1.37.1 h1:kZyzyCGV2osT3QPBfFLPwAU+mBodPOCngFDYEwQXpgk=
github.com/zap-proto/zip v1.37.1/go.mod h1:mYE5BMXclZ14Wz4tw/3ir+QBI7A7DPpi3ROXgwnXpfU=
github.com/zap-proto/zip v1.37.3 h1:QdSB0xqr4c7frwR8c+bVTQSWIpiavPYk3AnMXOpj/LA=
github.com/zap-proto/zip v1.37.3/go.mod h1:mYE5BMXclZ14Wz4tw/3ir+QBI7A7DPpi3ROXgwnXpfU=
github.com/zeebo/assert v1.3.0 h1:g7C04CbJuIDKNPFHmsk4hwZDO5O+kntRxzaUoNXj+IQ=
github.com/zeebo/assert v1.3.0/go.mod h1:Pq9JiuJQpG8JLJdtkwrJESF0Foym2/D9XMU5ciN/wJ0=
github.com/zeebo/blake3 v0.2.4 h1:KYQPkhpRtcqh0ssGYcKLG1JYvddkEA8QwCM/yBqhaZI=
+3 -2
View File
@@ -1,6 +1,7 @@
package org
import (
"net/http"
"os"
"path/filepath"
"strings"
@@ -19,7 +20,7 @@ func serveIAM(t *testing.T) (addr string, seen *string) {
var got string
app := zip.New(zip.Config{AppName: "iam-fake", DisableStartupMessage: true})
app.Get("/v1/iam/oauth/userinfo", func(c *zip.Ctx) error {
app.Raw(http.MethodGet, "/v1/iam/oauth/userinfo", func(c *zip.Ctx) error {
got = c.Header("Authorization")
return c.JSON(200, map[string]any{
"id": "u-1",
@@ -28,7 +29,7 @@ func serveIAM(t *testing.T) (addr string, seen *string) {
"orgIds": []string{"hanzo"},
})
})
app.Get("/v1/iam/keys/principal", func(c *zip.Ctx) error {
app.Raw(http.MethodGet, "/v1/iam/keys/principal", func(c *zip.Ctx) error {
if c.Query("accessKey") != "sk-probe" {
return c.JSON(400, map[string]string{"status": "error", "msg": "the entity does not exist"})
}
+1 -1
View File
@@ -179,7 +179,7 @@ func TestAppAnswersWhatTheAdaptedMuxAnswers(t *testing.T) {
t.Fatalf("BuildMux: %v", err)
}
adapted := zip.New(zip.Config{DisableStartupMessage: true})
adapted.All("/*", zip.AdaptNetHTTP(mux))
adapted.Raw(zip.MethodAll, "/*", zip.AdaptNetHTTP(mux))
app, err := r.BuildApp()
if err != nil {