handler.go

Overview

The handler.go file defines the main HTTP handler setup for the ADK REST API server. It constructs and configures a top-level HTTP router that serves the REST API endpoints related to agent sessions, runtime execution, applications, debugging, artifacts, and evaluation. This handler serves as the entry point for all incoming HTTP requests targeting the ADK REST API.

Key responsibilities of this file include:

This file plays a critical role in the REST API and Web Launchers topic by integrating routing, telemetry, and controller components into a unified HTTP handler serving the agent ecosystem.


Detailed Explanation of Components

Function: NewHandler

func NewHandler(config *launcher.Config) http.Handler

Function: setupRouter

func setupRouter(router *mux.Router, subrouters ...routers.Router) *mux.Router

Important Implementation Details


Interaction with Other Parts of the System

This file acts as the glue that binds the HTTP server, routing infrastructure, telemetry, and controller logic into a cohesive, operational REST API server.


Visual Diagram: Structure of handler.go

classDiagram
class Handler {
+NewHandler(config)
-setupRouter(router, subrouters)
}
class Router {
<<from mux>>
}
class SessionsAPIRouter {
<<from routers>>
}
class RuntimeAPIRouter {
<<from routers>>
}
class AppsAPIRouter {
<<from routers>>
}
class DebugAPIRouter {
<<from routers>>
}
class ArtifactsAPIRouter {
<<from routers>>
}
class EvalAPIRouter {
<<from routers>>
}
Handler --> Router : creates
Handler ..> SessionsAPIRouter : uses
Handler ..> RuntimeAPIRouter : uses
Handler ..> AppsAPIRouter : uses
Handler ..> DebugAPIRouter : uses
Handler ..> ArtifactsAPIRouter : uses
Handler ..> EvalAPIRouter : uses

References