mirror of
https://github.com/hanzoai/zip.git
synced 2026-10-30 20:11:40 +00:00
The import path a reader types is the one the org owns, rather than the forge that happens to host the bytes. hanzo.ai serves the go-import meta and points it at the same repository, so where the code lives does not change. The README's `go get` line moves with it — an install instruction naming the old path is the one leftover a reader would actually follow.
47 lines
1.2 KiB
Go
47 lines
1.2 KiB
Go
// migrate-from-beego example — beego → zip migration via http.Handler
|
|
// adapter. beego.BeeApp exposes Handlers as an http.Handler-compatible
|
|
// surface; the same Mount() entry that fronted chi handles beego too.
|
|
//
|
|
// In a real port:
|
|
//
|
|
// import (
|
|
// "github.com/beego/beego/v2/server/web"
|
|
// "hanzo.ai/zip"
|
|
// )
|
|
//
|
|
// beeApp := web.NewHttpSever() // your existing beego app
|
|
// zipApp := zip.New(zip.Config{AppName: "iam"})
|
|
// zipApp.Mount("/legacy/iam", beeApp.Handlers)
|
|
//
|
|
// This example uses a stand-in http.Handler so the file builds without
|
|
// pulling beego — same Mount() pattern in either case.
|
|
package main
|
|
|
|
import (
|
|
"log"
|
|
"net/http"
|
|
|
|
"hanzo.ai/zip"
|
|
)
|
|
|
|
type beegoStub struct{}
|
|
|
|
func (beegoStub) ServeHTTP(w http.ResponseWriter, _ *http.Request) {
|
|
w.Header().Set("Content-Type", "application/json")
|
|
_, _ = w.Write([]byte(`{"legacy_beego":true}`))
|
|
}
|
|
|
|
func main() {
|
|
app := zip.New(zip.Config{AppName: "migrate-from-beego"})
|
|
|
|
// New native zip routes:
|
|
app.Get("/v1/iam/healthz", func(c *zip.Ctx) error {
|
|
return c.JSON(200, map[string]string{"status": "ok"})
|
|
})
|
|
|
|
// Legacy beego app under /legacy/iam:
|
|
app.Mount("/legacy/iam", beegoStub{})
|
|
|
|
log.Fatal(app.Listen(":8080"))
|
|
}
|