main.go 606 Bytes
Newer Older
1
2
3
package main

import (
Fredrik Lønnemo's avatar
Fredrik Lønnemo committed
4
	internal "assignment2"
5
6
7
8
9
10
11
12
13
14
15
16
17
	"fmt"
	"log"
	"net/http"
	"os"
)

func main() {

	port := os.Getenv("PORT")
	if port == "" {
		port = "8080"
	}

Fredrik Lønnemo's avatar
Fredrik Lønnemo committed
18
19
20
21
22
	http.HandleFunc("/", internal.HandlerHome)
	http.HandleFunc("/corona/v1/country/", internal.HandlerCountry)
	http.HandleFunc("/corona/v1/policy/", internal.HandlerPolicy)
	http.HandleFunc("/corona/v1/diag/", internal.HandlerDiagnostics)
	http.HandleFunc("/corona/v1/notifications/", internal.HandlerNotifications)
23

Fredrik Lønnemo's avatar
Fredrik Lønnemo committed
24
25
	fmt.Println("Running on port ", port)
	err := http.ListenAndServe(":"+port, nil)
26
27
28
29
	if err != nil {
		log.Fatal(err.Error())
	}
}