-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
31 lines (26 loc) · 798 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"
"time"
"github.com/gorilla/mux"
"github.com/iZonex/device-control/handlers"
)
func main() {
r := mux.NewRouter()
fs := http.FileServer(http.Dir("./static/"))
r.HandleFunc("/", handlers.WifiHandler).Methods("GET")
r.HandleFunc("/status", handlers.MainHandler).Methods("GET")
r.HandleFunc("/api/status", handlers.DeviceInformationHandler).Methods("GET")
r.HandleFunc("/wifi", handlers.WifiHandler).Methods("GET")
r.PathPrefix("/static/").Handler(http.StripPrefix("/static/", fs))
r.HandleFunc("/server", handlers.ServerHandler).Methods("GET")
http.Handle("/", r)
srv := &http.Server{
Handler: r,
Addr: "0.0.0.0:8080",
WriteTimeout: 15 * time.Second,
ReadTimeout: 15 * time.Second,
}
log.Fatal(srv.ListenAndServe())
}