StatusApp/server/server.go

22 lines
408 B
Go

package server
import (
"fmt"
"net/http"
"strconv"
)
func apiEndpoints() {
http.HandleFunc("/api/latest", allStatus)
http.HandleFunc("/api/history/day", dayHistory)
http.HandleFunc("/api/history/week", weekHistory)
}
func StartServer(port int) {
apiEndpoints()
err := http.ListenAndServe(":"+strconv.Itoa(port), nil)
if err != nil {
fmt.Printf("ListenAndServe returned an error: %v", err)
}
}