Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ListenAndServe ¶
ListenAndServe starts the server and blocks until shutdown signal.
Types ¶
type ErrorResponse ¶
ErrorResponse is the JSON response for errors.
type Handlers ¶
type Handlers struct {
// contains filtered or unexported fields
}
Handlers holds the HTTP handlers and their dependencies.
func NewHandlers ¶
func NewHandlers(router routing.Router, stats StatsResponse) *Handlers
NewHandlers creates handlers with the given router.
func (*Handlers) HandleHealth ¶
func (h *Handlers) HandleHealth(w http.ResponseWriter, r *http.Request)
HandleHealth handles GET /api/v1/health.
func (*Handlers) HandleRoute ¶
func (h *Handlers) HandleRoute(w http.ResponseWriter, r *http.Request)
HandleRoute handles POST /api/v1/route.
func (*Handlers) HandleStats ¶
func (h *Handlers) HandleStats(w http.ResponseWriter, r *http.Request)
HandleStats handles GET /api/v1/stats.
type HealthResponse ¶
type HealthResponse struct {
Status string `json:"status"`
}
HealthResponse is the JSON response for GET /api/v1/health.
type LatLngJSON ¶
LatLngJSON represents a lat/lng pair in JSON.
type RouteRequest ¶
type RouteRequest struct {
Start LatLngJSON `json:"start"`
End LatLngJSON `json:"end"`
}
RouteRequest is the JSON body for POST /api/v1/route.
type RouteResponse ¶
type RouteResponse struct {
TotalDistanceMeters float64 `json:"total_distance_meters"`
Segments []SegmentJSON `json:"segments"`
}
RouteResponse is the JSON response for a successful route query.
type SegmentJSON ¶
type SegmentJSON struct {
DistanceMeters float64 `json:"distance_meters"`
Geometry []LatLngJSON `json:"geometry"`
}
SegmentJSON represents a road segment in the response.
type ServerConfig ¶
type ServerConfig struct {
Addr string
ReadTimeout time.Duration
WriteTimeout time.Duration
MaxConcurrent int
CORSOrigin string
}
ServerConfig holds server configuration.
func DefaultConfig ¶
func DefaultConfig(addr string) ServerConfig
DefaultConfig returns sensible defaults.
type StatsResponse ¶
type StatsResponse struct {
NumNodes uint32 `json:"num_nodes"`
NumFwdEdges int `json:"num_fwd_edges"`
NumBwdEdges int `json:"num_bwd_edges"`
}
StatsResponse is the JSON response for GET /api/v1/stats.