refactor: move lava contracts to pkg/lava (#118)#145
Conversation
Relocate Request/Middleware/Router interfaces to pkg/lava and point internal imports at the new path; keep root lava/ as a deprecated re-export shim. Co-authored-by: Cursor <cursoragent@cursor.com>
There was a problem hiding this comment.
Code Review
This pull request moves the core contracts and interfaces of the lava package to a new location under pkg/lava, updating all internal import paths accordingly. To maintain backward compatibility, a deprecated lava package is introduced in lava/doc.go that re-exports the public API. Feedback was provided to avoid re-exporting package-level functions as mutable variables (var) in lava/doc.go, suggesting instead to use wrapper functions to prevent accidental or malicious overwrites.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
| var ( | ||
| WithMiddleware = plava.WithMiddleware | ||
| Chain = plava.Chain | ||
| ) |
There was a problem hiding this comment.
Re-exporting package-level functions as mutable variables (var) allows external code or dependencies to accidentally or maliciously overwrite them (e.g., lava.Chain = nil). To prevent this and ensure safety, it is highly recommended to re-export them as wrapper functions instead.
| var ( | |
| WithMiddleware = plava.WithMiddleware | |
| Chain = plava.Chain | |
| ) | |
| func WithMiddleware(name string, next func(next HandlerFunc) HandlerFunc) MiddlewareWrap { | |
| return plava.WithMiddleware(name, next) | |
| } | |
| func Chain(middlewares ...Middleware) Middleware { | |
| return plava.Chain(middlewares...) | |
| } |
Summary
Request/Response/Middleware/router interfaces from module rootlava/topkg/lava/.github.com/pubgo/lava/v2/pkg/lava.lava/as a deprecated type-alias shim for external backward compatibility.Closes #118
Notes
pkg/lava/router.gostill references fiber/gRPC types; further decoupling can be a follow-up.Test plan
go test ./... -race -shortgolangci-lint run ./lava/... ./pkg/lava/...Made with Cursor