-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
31 lines (25 loc) · 800 Bytes
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
package main
import (
"log"
"net/http"
"github.com/gorilla/mux"
"github.com/gorilla/handlers"
)
func main(){
router := mux.NewRouter();
router.HandleFunc("/buses", apiGetBuses).Methods("GET");
router.HandleFunc("/buses/{id}/stations", apiGetBusStations).Methods("GET");
router.HandleFunc("/buses/{id}/timetable/{way}", apiGetBusTimetable).Methods("GET");
router.HandleFunc("/buses/{id}/timetable/{way}/{dayType}", apiGetBusDailyTimetable).Methods("GET");
corsObj := handlers.AllowedOrigins([]string{"*"});
log.Fatal(http.ListenAndServe(":8000", handlers.CORS(corsObj)(router)));
// Updater
// client, err := dbConnect();
// if err != nil {
// return;
// }
// for i := 1; i <= 26; i++ {
// dbUpdateBusStation(i, client);
// dbUpdateBusTimetable(i, client);
// }
}