feat: support serverless in rest (#5001)

Signed-off-by: kevin <wanjunfeng@gmail.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
This commit is contained in:
Kevin Wan
2025-07-13 00:00:52 +08:00
committed by GitHub
parent a71e56de52
commit c9ff6a10d3
4 changed files with 106 additions and 2 deletions

View File

@@ -119,6 +119,16 @@ func (s *Server) Use(middleware Middleware) {
s.ngin.use(middleware)
}
// build builds the Server and binds the routes to the router.
func (s *Server) build() error {
return s.ngin.bindRoutes(s.router)
}
// serve serves the HTTP requests using the Server's router.
func (s *Server) serve(w http.ResponseWriter, r *http.Request) {
s.router.ServeHTTP(w, r)
}
// ToMiddleware converts the given handler to a Middleware.
func ToMiddleware(handler func(next http.Handler) http.Handler) Middleware {
return func(handle http.HandlerFunc) http.HandlerFunc {