Improvement
#257: Return http.Handler instead of SetupRouter in server/restapi/web (#259)
Arjun Mehta
2 months ago
Commit: cffe3b0
Date: November 12, 2025 at 12:18 PM
- Add NewHandler() function to return http.Handler instead of requiring mux.Router - Created NewHandler() that returns standard http.Handler for better decoupling - Marked SetupRouter() as deprecated for backward compatibility - Allows users to use ADK REST API with any HTTP server/router, not just gorilla/mux
- Update api launcher to use NewHandler() instead of SetupRouter() - Refactored SetupSubrouters to use web.NewHandler() - Wraps handler with CORS middleware before registration - Uses http.StripPrefix for proper path handling - No breaking changes to web launcher interface
- Add example demonstrating NewHandler() usage with standard net/http - Shows how to use web.NewHandler() with net/http.ServeMux - Demonstrates framework-agnostic approach - Includes health check endpoint to show composability - Example works with any HTTP server/router, not tied to gorilla/mux
- Resolve PR feedback: remove SetupRouter and update example to use launcher.Config
- Clean up comments in NewHandler and setupRouter
Removed comments about the preferred integration method and the public SetupRouter helper.
- Fix linter issues: handle w.Write error and format with goimports
- Fix missing newline at end of api.go
Add a newline at the end of the file.
- Fix goimports formatting: remove trailing blank line and handle w.Write error
---------
Co-authored-by: Dmitry Pasiukevich
Powered by ChangeCrab