fix: address code review findings
This commit is contained in:
@@ -39,6 +39,35 @@ func main() {
|
||||
http.HandleFunc("/internal/admin/stations/", makeHandler(AdminStationStatus, handlerCtx))
|
||||
http.HandleFunc("/metrics", makeHandler(MetricsHandler, handlerCtx))
|
||||
|
||||
// User preferences routes
|
||||
http.HandleFunc("/v1/preferences/saved-cities", func(w http.ResponseWriter, r *http.Request) {
|
||||
switch r.Method {
|
||||
case http.MethodGet:
|
||||
GetSavedCities(handlerCtx, w, r)
|
||||
case http.MethodPost:
|
||||
AddSavedCity(handlerCtx, w, r)
|
||||
default:
|
||||
http.Error(w, "method not allowed", http.StatusMethodNotAllowed)
|
||||
}
|
||||
})
|
||||
http.HandleFunc("/v1/preferences/saved-cities/", func(w http.ResponseWriter, r *http.Request) {
|
||||
if r.Method == http.MethodDelete {
|
||||
RemoveSavedCity(handlerCtx, w, r)
|
||||
} else {
|
||||
http.Error(w, "method not allowed", http.StatusMethodNotAllowed)
|
||||
}
|
||||
})
|
||||
http.HandleFunc("/v1/preferences/search-history", func(w http.ResponseWriter, r *http.Request) {
|
||||
switch r.Method {
|
||||
case http.MethodGet:
|
||||
GetSearchHistory(handlerCtx, w, r)
|
||||
case http.MethodPost:
|
||||
AddSearchHistory(handlerCtx, w, r)
|
||||
default:
|
||||
http.Error(w, "method not allowed", http.StatusMethodNotAllowed)
|
||||
}
|
||||
})
|
||||
|
||||
log.Println("Trip Planner API starting on :8080")
|
||||
log.Fatal(http.ListenAndServe(":8080", nil))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user