forked from robertoduessmann/weather-api
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
34 lines (26 loc) · 755 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
32
33
34
package main
import (
"log"
"net/http"
"github.com/gorilla/handlers"
"github.com/gorilla/mux"
"github.com/robertoduessmann/weather-api/config"
"github.com/robertoduessmann/weather-api/controller"
v2 "github.com/robertoduessmann/weather-api/controller/v2"
)
func main() {
weather := mux.NewRouter()
weather.Path("/weather/{city}").Methods(http.MethodGet).HandlerFunc(controller.CurrentWeather)
weather.
Path("/v2/weather/{city}").
Queries("unit", "{unit}").
Methods(http.MethodGet).
HandlerFunc(v2.CurrentWeather)
weather.
Path("/v2/weather/{city}").
Methods(http.MethodGet).
HandlerFunc(v2.CurrentWeather)
if err := http.ListenAndServe(":"+config.Get().Port, handlers.CORS()(weather)); err != nil {
log.Fatal(err)
}
}