Documentation
¶
Overview ¶
Package handlers provides reverse proxy handlers for each datasource type.
Index ¶
- Constants
- func WithDatasourceRoute(ctx context.Context, routeName string) context.Context
- type BenchmarkoorConfig
- type BenchmarkoorHandler
- type ClickHouseConfig
- type ClickHouseHandler
- func (h *ClickHouseHandler) AddCluster(cfg ClickHouseConfig)
- func (h *ClickHouseHandler) ClusterConfig(name string) (ClickHouseConfig, bool)
- func (h *ClickHouseHandler) Clusters() []string
- func (h *ClickHouseHandler) HasCluster(name string) bool
- func (h *ClickHouseHandler) RemoveCluster(name string)
- func (h *ClickHouseHandler) ServeHTTP(w http.ResponseWriter, r *http.Request)
- type ComputeConfig
- type ComputeHandler
- type EthNodeConfig
- type EthNodeHandler
- type FaucetConfig
- type FaucetHandler
- type GitHubConfig
- type GitHubHandler
- type GitHubRunStatusRequest
- type GitHubRunStatusResponse
- type GitHubTriggerRequest
- type GitHubTriggerResponse
- type GlobalTriggerRateLimiter
- type LokiConfig
- type LokiHandler
- type PrometheusConfig
- type PrometheusHandler
- type UploadsConfig
- type UploadsHandler
- type WorkflowConfig
- type WorkflowHandler
Constants ¶
const ( // WorkflowAuthModeToken injects the proxy-held api_token as the bearer; the // inbound proxy bearer never reaches upstream. WorkflowAuthModeToken = "token" // WorkflowAuthModePassthrough re-attaches the caller's own bearer unchanged // so the engine validates the user's token directly. WorkflowAuthModePassthrough = "passthrough" )
Workflow auth modes select how the proxy credentials the upstream engine.
const DatasourceHeader = "X-Datasource"
DatasourceHeader is the HTTP header used to specify which datasource to route to.
const DefaultMaxObjectBytes int64 = 100 << 20
DefaultMaxObjectBytes caps a single upload at 100 MiB.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type BenchmarkoorConfig ¶ added in v0.33.0
BenchmarkoorConfig holds benchmarkoor proxy configuration for a single datasource.
type BenchmarkoorHandler ¶ added in v0.33.0
type BenchmarkoorHandler struct {
// contains filtered or unexported fields
}
BenchmarkoorHandler handles requests to benchmarkoor API datasources. The datasource is specified via the X-Datasource header. Only read methods are forwarded: benchmarkoor API keys are read-only upstream, and the proxy enforces the same boundary before spending a request.
func NewBenchmarkoorHandler ¶ added in v0.33.0
func NewBenchmarkoorHandler(log logrus.FieldLogger, configs []BenchmarkoorConfig) *BenchmarkoorHandler
NewBenchmarkoorHandler creates a new benchmarkoor handler.
func (*BenchmarkoorHandler) ServeHTTP ¶ added in v0.33.0
func (h *BenchmarkoorHandler) ServeHTTP(w http.ResponseWriter, r *http.Request)
ServeHTTP rejects non-read methods before delegating to the generic datasource router.
type ClickHouseConfig ¶
type ClickHouseConfig struct {
Name string
RouteName string
Description string
Host string
Port int
Database string
Username string
Password string
Secure bool
SkipVerify bool
Timeout int
}
ClickHouseConfig holds ClickHouse proxy configuration for a single datasource.
type ClickHouseHandler ¶
type ClickHouseHandler struct {
// contains filtered or unexported fields
}
ClickHouseHandler handles requests to ClickHouse datasources. Datasources may be added or removed at runtime (e.g. by autodiscovery), so all access to the datasource map and name list is guarded by mu.
func NewClickHouseHandler ¶
func NewClickHouseHandler(log logrus.FieldLogger, configs []ClickHouseConfig) *ClickHouseHandler
NewClickHouseHandler creates a new ClickHouse handler.
func (*ClickHouseHandler) AddCluster ¶ added in v0.26.0
func (h *ClickHouseHandler) AddCluster(cfg ClickHouseConfig)
AddCluster adds or replaces a ClickHouse datasource at runtime.
func (*ClickHouseHandler) ClusterConfig ¶ added in v0.26.0
func (h *ClickHouseHandler) ClusterConfig(name string) (ClickHouseConfig, bool)
ClusterConfig returns the current configuration for a datasource name.
func (*ClickHouseHandler) Clusters ¶
func (h *ClickHouseHandler) Clusters() []string
Clusters returns the list of configured ClickHouse datasource names.
func (*ClickHouseHandler) HasCluster ¶ added in v0.26.0
func (h *ClickHouseHandler) HasCluster(name string) bool
HasCluster reports whether a datasource is currently configured.
func (*ClickHouseHandler) RemoveCluster ¶ added in v0.26.0
func (h *ClickHouseHandler) RemoveCluster(name string)
RemoveCluster removes a ClickHouse datasource at runtime.
func (*ClickHouseHandler) ServeHTTP ¶
func (h *ClickHouseHandler) ServeHTTP(w http.ResponseWriter, r *http.Request)
ServeHTTP handles ClickHouse requests. The datasource is specified via X-Datasource header.
type ComputeConfig ¶ added in v0.38.0
ComputeConfig holds compute proxy configuration for a single datasource.
type ComputeHandler ¶ added in v0.38.0
type ComputeHandler struct {
// contains filtered or unexported fields
}
ComputeHandler handles requests to compute API datasources. The datasource is specified via the X-Datasource header. Unlike read-only datasources, all HTTP methods are forwarded: the compute backend manages mutable resources (sandboxes, images) and authorizes each request itself.
The proxy has already verified the caller's OIDC bearer token (and gated access via allowed_orgs); the handler forwards that same token to the compute backend, which validates it directly and derives the end-user identity from it. There is no shared service token and no forwarded-subject header.
func NewComputeHandler ¶ added in v0.38.0
func NewComputeHandler(log logrus.FieldLogger, configs []ComputeConfig) *ComputeHandler
NewComputeHandler creates a new compute handler.
type EthNodeConfig ¶
EthNodeConfig holds credentials for Ethereum node API access. A single credential pair is used for all bn-*.srv.*.ethpandaops.io and rpc-*.srv.*.ethpandaops.io endpoints.
type EthNodeHandler ¶
type EthNodeHandler struct {
// contains filtered or unexported fields
}
EthNodeHandler proxies requests to Ethereum beacon and execution nodes. Unlike other handlers that use static reverse proxies per instance, this handler constructs upstream URLs dynamically from path segments.
func NewEthNodeHandler ¶
func NewEthNodeHandler(log logrus.FieldLogger, cfg EthNodeConfig) *EthNodeHandler
NewEthNodeHandler creates a new Ethereum node handler.
func (*EthNodeHandler) ServeHTTP ¶
func (h *EthNodeHandler) ServeHTTP(w http.ResponseWriter, r *http.Request)
ServeHTTP handles beacon and execution node requests. Path format: /{beacon|execution}/{network}/{instance}/... The first segment (beacon/execution) determines the upstream host pattern.
type FaucetConfig ¶ added in v0.38.8
FaucetConfig holds the basic-auth credential for the per-network agent PoW faucet. The faucet ingress is credential-gated (not open), and only the proxy holds this pair — so panda users can reach the faucet solely through the proxy, which authenticates them first.
type FaucetHandler ¶ added in v0.38.8
type FaucetHandler struct {
// contains filtered or unexported fields
}
FaucetHandler reverse-proxies agent PoW faucet requests to the network's faucet host, attaching the basic-auth credential. Path: /faucet/{network}/... It mirrors EthNodeHandler but has no per-instance segment (one faucet/network).
func NewFaucetHandler ¶ added in v0.38.8
func NewFaucetHandler(log logrus.FieldLogger, cfg FaucetConfig) *FaucetHandler
NewFaucetHandler creates a new faucet handler.
func (*FaucetHandler) ServeHTTP ¶ added in v0.38.8
func (h *FaucetHandler) ServeHTTP(w http.ResponseWriter, r *http.Request)
ServeHTTP handles /faucet/{network}/{rest...}, forwarding {rest} (and the query string) to the network's faucet.
type GitHubConfig ¶ added in v0.22.0
type GitHubConfig struct {
Token string
}
GitHubConfig holds GitHub API proxy configuration.
type GitHubHandler ¶ added in v0.22.0
type GitHubHandler struct {
// contains filtered or unexported fields
}
GitHubHandler handles GitHub API requests.
func NewGitHubHandler ¶ added in v0.22.0
func NewGitHubHandler(log logrus.FieldLogger, cfg GitHubConfig, globalLimiter GlobalTriggerRateLimiter) *GitHubHandler
NewGitHubHandler creates a new GitHub handler. globalLimiter enforces the cross-workflow trigger budget; it may be nil to disable that budget.
func (*GitHubHandler) ServeHTTP ¶ added in v0.22.0
func (h *GitHubHandler) ServeHTTP(w http.ResponseWriter, r *http.Request)
ServeHTTP routes GitHub API requests.
type GitHubRunStatusRequest ¶ added in v0.22.0
type GitHubRunStatusRequest struct {
Repository string `json:"repository"`
RunID int64 `json:"run_id"`
}
GitHubRunStatusRequest is the request for checking a run's status.
type GitHubRunStatusResponse ¶ added in v0.22.0
type GitHubRunStatusResponse struct {
RunID int64 `json:"run_id"`
Status string `json:"status"`
Conclusion string `json:"conclusion"`
HTMLURL string `json:"html_url"`
}
GitHubRunStatusResponse is the response from a run status check.
type GitHubTriggerRequest ¶ added in v0.22.0
type GitHubTriggerRequest struct {
// Repository is the target GitHub repository (e.g. "ethpandaops/eth-client-docker-image-builder").
Repository string `json:"repository"`
// Workflow is the workflow filename (e.g. "build-push-geth.yml").
Workflow string `json:"workflow"`
// Ref is the git ref to run the workflow on (typically "master").
Ref string `json:"ref"`
// Inputs are the workflow_dispatch inputs.
Inputs map[string]string `json:"inputs,omitempty"`
}
GitHubTriggerRequest is the request body for triggering a workflow.
type GitHubTriggerResponse ¶ added in v0.22.0
type GitHubTriggerResponse struct {
WorkflowURL string `json:"workflow_url"`
RunID int64 `json:"run_id,omitempty"`
RunURL string `json:"run_url,omitempty"`
}
GitHubTriggerResponse is the response from a successful workflow trigger.
type GlobalTriggerRateLimiter ¶ added in v0.30.0
GlobalTriggerRateLimiter enforces the cross-workflow trigger budget. It is satisfied by the proxy's generic rate limiter; Allow consumes one unit from the bucket identified by key and reports whether the trigger may proceed.
type LokiConfig ¶
type LokiConfig struct {
Name string
RouteName string
Description string
URL string
Username string
Password string
}
LokiConfig holds Loki proxy configuration for a single datasource.
type LokiHandler ¶
type LokiHandler struct {
// contains filtered or unexported fields
}
LokiHandler handles requests to Loki datasources. The datasource is specified via the X-Datasource header.
func NewLokiHandler ¶
func NewLokiHandler(log logrus.FieldLogger, configs []LokiConfig) *LokiHandler
NewLokiHandler creates a new Loki handler.
type PrometheusConfig ¶
type PrometheusConfig struct {
Name string
RouteName string
Description string
URL string
Username string
Password string
}
PrometheusConfig holds Prometheus proxy configuration for a single datasource.
type PrometheusHandler ¶
type PrometheusHandler struct {
// contains filtered or unexported fields
}
PrometheusHandler handles requests to Prometheus datasources. The datasource is specified via the X-Datasource header.
func NewPrometheusHandler ¶
func NewPrometheusHandler(log logrus.FieldLogger, configs []PrometheusConfig) *PrometheusHandler
NewPrometheusHandler creates a new Prometheus handler.
type UploadsConfig ¶ added in v0.38.0
type UploadsConfig struct {
Bucket string
KeyPrefix string
PublicBaseURL string
Endpoint string
AccessKeyID string
SecretKey string
MaxObjectBytes int64
// TeamKeyPrefix/TeamBaseURL enable team-visibility publishes: same bucket,
// separate prefix, served from an Access-protected domain. Both must be set
// for ?visibility=team to be accepted.
TeamKeyPrefix string
TeamBaseURL string
// RenderHTML lets text/html serve inline instead of being forced to
// download. Enable it ONLY once the bucket's public domain carries a
// Cloudflare Transform Rule that sets
// Content-Security-Policy: sandbox allow-scripts allow-downloads
// on text/html responses. That header pins uploaded HTML to an opaque
// origin (no cookies, no credentialed same-origin fetch, can't act as the
// bucket domain), which is what makes rendering shared HTML diagnostics
// safe. Without the rule, inline HTML would execute with full privileges
// on the bucket origin — so this defaults off and forces download.
RenderHTML bool
}
UploadsConfig configures the R2 (S3-compatible) bucket backing the /uploads route.
type UploadsHandler ¶ added in v0.38.0
type UploadsHandler struct {
// contains filtered or unexported fields
}
UploadsHandler streams request bodies to an R2 bucket and returns a durable public URL. It is the credentialed half of `panda upload` — R2 keys never leave the proxy.
func NewUploadsHandler ¶ added in v0.38.0
func NewUploadsHandler(log logrus.FieldLogger, cfg UploadsConfig) (*UploadsHandler, error)
NewUploadsHandler builds an R2-backed uploads handler.
func (*UploadsHandler) ServeHTTP ¶ added in v0.38.0
func (h *UploadsHandler) ServeHTTP(w http.ResponseWriter, r *http.Request)
ServeHTTP routes the authenticated /uploads surface: POST publishes a new object, DELETE removes one. There is deliberately no list route — published URLs are content-addressed capability URLs, and deleting requires already knowing the URL; a listing would let any authenticated user enumerate everything anyone has shared.
type WorkflowConfig ¶ added in v0.38.0
type WorkflowConfig struct {
// URL is the workflow engine API origin (bare scheme+host[:port], no path).
URL string
// AuthMode is "token" or "passthrough".
AuthMode string
// APIToken is the bearer injected in "token" mode.
APIToken string
}
WorkflowConfig holds the workflow-engine passthrough handler configuration.
type WorkflowHandler ¶ added in v0.38.0
type WorkflowHandler struct {
// contains filtered or unexported fields
}
WorkflowHandler is a thin credentialed reverse proxy to the workflow engine API. It clamps and cleans the request path, forwards a strict header allow-list, sets Authorization per auth mode, and streams responses (SSE-safe). All HTTP methods are forwarded: the engine manages mutable resources and authorizes each request itself.
func NewWorkflowHandler ¶ added in v0.38.0
func NewWorkflowHandler(log logrus.FieldLogger, cfg WorkflowConfig) (*WorkflowHandler, error)
NewWorkflowHandler builds a workflow passthrough for the given config. It returns an error when the configured URL cannot be parsed.
func (*WorkflowHandler) ServeHTTP ¶ added in v0.38.0
func (h *WorkflowHandler) ServeHTTP(w http.ResponseWriter, r *http.Request)
ServeHTTP resolves and clamps the request path, then proxies the request. It clears the response write deadline so SSE streams outlive server.write_timeout.