Files
zeekayandHanzo Dev 0a22533cda control-plane: route the HTTP surface on zip v1.10.0
Move the control-plane's REST/UI surface off gin's router and onto
github.com/zap-proto/zip v1.10.0 (over zap-proto/http v0.3.0). zip now owns
routing, the middleware chain and the transport; all 130 routes are registered
natively via App.Get/Post/Put/Patch/Delete and App.Group.

The route table is unchanged: 130 method+path pairs before and after, verified
by diff. The only spelling change is the wildcard leaf, "/ui/*filepath" ->
"/ui/*", which matches the same paths.

Handlers are fronted rather than rewritten. ~24k lines of gin handler bodies
are this service's public API and a hand port of that volume cannot be proven
equivalent, so internal/server/ginbridge.go provides the one seam:

  ginHandler(h)     wraps a gin.HandlerFunc, copying the matched zip route's
                    params onto the gin context so c.Param(...) still works.
  ginChain(mws...)  runs the gin middleware stack (CORS, access log, timeout,
                    API-key auth) unmodified, so CORS origin echoing and the
                    auth abort bodies stay byte-for-byte identical.

The net/http adaptor underneath supports buffered, flushed and hijacked
responses, so the SSE and WebSocket routes keep streaming through the same
seam rather than being rewritten badly.

Two things that would otherwise silently break the API:

  - Start listens on "http://:PORT". A bare address binds zip's default ZAP
    transport, which would change the wire protocol of the REST surface.
  - The NoRoute fallback is All("/+"), not All("/*"). "/*" also matches "/"
    and shadowed the root redirect, turning it into a 404.

Coverage: routes_test.go pins the exact 130-route table and the NoRoute
semantics; ginbridge_test.go pins params, status, body, CORS echo, auth abort
and SSE through the bridge. Both pass under the default and "embedded" build
tags. A package TestMain sets gin's mode once, removing the pre-existing
gin.SetMode data race between parallel tests in this package.

Co-authored-by: Hanzo Dev <[email protected]>
2026-08-13 11:48:06 -07:00

13 lines
355 B
Go

//go:build !embedded
package client
import "github.com/zap-proto/zip"
// RegisterUIRoutes is a no-op when the UI is not embedded.
// The server will serve UI assets from the filesystem when configured.
func RegisterUIRoutes(_ *zip.App) {}
// IsUIEmbedded reports whether UI assets are embedded in the binary.
func IsUIEmbedded() bool { return false }