Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Use ¶
Use integrates the do library's web-based debugging interface with a Chi router. This function sets up HTTP routes for the debugging UI, allowing you to inspect your DI container through a web browser using the Chi framework.
Parameters:
- router: The Chi router to add the debugging routes to
- basePath: The base URL path for the debugging interface
- injector: The injector instance to debug
The function sets up the following routes:
- GET {basePath}: The main debugging interface home page
- GET {basePath}/scope: Scope tree visualization with optional scope_id parameter
- GET {basePath}/service: Service inspection with optional scope_id and service_name parameters
Example:
r := chi.NewRouter()
api := r.Route("/api", nil)
// Add the debugging interface
dochi.Use(r, "/debug/di", injector)
// Your application routes
api.Get("/users", userHandler)
The debugging interface will be available at /debug/di and provides:
- Visual representation of scope hierarchy
- Service dependency graphs
- Service inspection and debugging tools
- Navigation between different views
Chi routes are registered with the full basePath, so the debugging interface will be available at the exact path specified in basePath.
Security: Do not expose these routes publicly in production. They reveal internal details about your DI graph. Protect the basePath with authentication (e.g., Basic Auth) and/or network restrictions. Apply your auth middleware before calling Use.
Types ¶
This section is empty.