api

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Jan 29, 2026 License: Apache-2.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func LoggingMiddleware

func LoggingMiddleware(next http.Handler) http.Handler

LoggingMiddleware logs method, path, query, status, and duration

Types

type ReportRequest

type ReportRequest struct {
	SiteID            *int    `json:"site_id"`            // Optional: use site configuration
	StartDate         string  `json:"start_date"`         // YYYY-MM-DD format
	EndDate           string  `json:"end_date"`           // YYYY-MM-DD format
	CompareStart      string  `json:"compare_start_date"` // Optional: comparison start date (YYYY-MM-DD)
	CompareEnd        string  `json:"compare_end_date"`   // Optional: comparison end date (YYYY-MM-DD)
	Timezone          string  `json:"timezone"`           // e.g., "US/Pacific"
	Units             string  `json:"units"`              // "mph" or "kph"
	Group             string  `json:"group"`              // e.g., "1h", "4h"
	Source            string  `json:"source"`             // "radar_objects" or "radar_data_transits"
	CompareSource     string  `json:"compare_source"`     // Optional: source for comparison period (defaults to Source)
	MinSpeed          float64 `json:"min_speed"`          // minimum speed filter
	BoundaryThreshold int     `json:"boundary_threshold"` // filter boundary hours with < N samples (default: 5)
	Histogram         bool    `json:"histogram"`          // whether to generate histogram
	HistBucketSize    float64 `json:"hist_bucket_size"`   // histogram bucket size
	HistMax           float64 `json:"hist_max"`           // histogram max value

	// These can be overridden if site_id is not provided
	Location        string `json:"location"`         // site location
	Surveyor        string `json:"surveyor"`         // surveyor name
	Contact         string `json:"contact"`          // contact info
	SpeedLimit      int    `json:"speed_limit"`      // posted speed limit
	SiteDescription string `json:"site_description"` // site description
}

ReportRequest represents the JSON payload for report generation

type Server

type Server struct {
	// contains filtered or unexported fields
}

func NewServer

func NewServer(m serialmux.SerialMuxInterface, db *db.DB, units string, timezone string) *Server

func (*Server) ServeMux

func (s *Server) ServeMux() *http.ServeMux

func (*Server) SetTransitController

func (s *Server) SetTransitController(tc TransitController)

SetTransitController sets the transit controller for the server. This allows the API to provide UI controls for the transit worker.

func (*Server) Start

func (s *Server) Start(ctx context.Context, listen string, devMode bool) error

Note: Start retrieves the mux by calling s.ServeMux(). ServeMux() returns the Server's stored *http.ServeMux (creating and storing it on first call). Callers are therefore free to call s.ServeMux() and register additional admin/diagnostic routes before invoking Start — those routes will be preserved and served. This avoids losing preconfigured routes when starting the server.

type TransitController

type TransitController interface {
	IsEnabled() bool
	SetEnabled(enabled bool)
	TriggerManualRun()
	TriggerFullHistoryRun()
	GetStatus() db.TransitStatus
}

TransitController is an interface for controlling the transit worker. This allows the API server to toggle the worker without direct coupling.

Jump to

Keyboard shortcuts

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