mirror of
https://github.com/zap-proto/zip.git
synced 2026-10-19 15:38:57 +00:00
An App becomes a PROGRAM: an ordered list of entries, each carrying one of exactly three payloads — middleware, a route, or another App INCLUDED BY REFERENCE. One walk flattens it into occurrences in preorder; every projection is a reducer over that slice. Graft, Mount and Add delegate to the same walk. Five verbs existed because the op registry was a FIELD that composition appended to at call time, so composing two apps meant merging two registries and AdaptNetHTTP could destroy five projections by type-erasing an *App. A projection over a walk needs no merge rule. Prototype only: not for main, not tagged, not released. Co-authored-by: Hanzo Dev <[email protected]>
16 lines
664 B
Go
16 lines
664 B
Go
package zip
|
|
|
|
import "github.com/valyala/fasthttp"
|
|
|
|
// TestCtx returns a detached *Ctx over a synthetic request — the unit-test
|
|
// analog of a live request context, for calling a Handler directly. Integration
|
|
// tests should prefer app.Fiber().Test(req), which exercises routing and the
|
|
// full middleware chain; this exists for the narrower "call this one handler
|
|
// with locals seeded" idiom. The Ctx is not pooled; do not release it.
|
|
func (a *App) TestCtx(method, path string) *Ctx {
|
|
fctx := &fasthttp.RequestCtx{}
|
|
fctx.Request.Header.SetMethod(method)
|
|
fctx.Request.URI().SetPath(path)
|
|
return &Ctx{fc: a.router().AcquireCtx(fctx), app: a, log: a.logger}
|
|
}
|