dohttpstd

package module
v2.0.0-...-0b30a36 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 10, 2025 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Use

func Use(basePath string, injector do.Injector) http.Handler

Use creates an HTTP handler for the do library's web-based debugging interface using the standard Go net/http package. This function returns a handler that can be integrated with any standard HTTP server or router.

Parameters:

  • basePath: The base URL path for the debugging interface
  • injector: The injector instance to debug

Returns an http.Handler that serves the debugging interface.

The handler sets up the following routes:

  • GET /: The main debugging interface home page
  • GET /scope: Scope tree visualization with optional scope_id parameter
  • GET /service: Service inspection with optional scope_id and service_name parameters

Example:

// Create the debugging handler
debugHandler := std.Use("/debug/di", injector)

// Mount it in your server
mux := http.NewServeMux()
mux.Handle("/debug/di/", debugHandler)

// Your application routes
mux.HandleFunc("/api/users", userHandler)

// Start the server
http.ListenAndServe(":8080", mux)

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

The handler automatically strips the basePath prefix from incoming requests to ensure proper routing within the debugging interface.

Security: Do not expose this debug UI publicly in production. It reveals internal details about your application's DI graph. Protect these routes with authentication (for example, Basic Auth) and/or network restrictions (IP allowlist, VPN, etc.). Wrap this handler with your auth/middleware before mounting it.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL