Make use of the config
This commit is contained in:
parent
34c0712825
commit
2349fad4f4
1 changed files with 11 additions and 7 deletions
|
@ -47,9 +47,11 @@ func main() {
|
||||||
conf.WriteConfigToFile("config.toml")
|
conf.WriteConfigToFile("config.toml")
|
||||||
}
|
}
|
||||||
|
|
||||||
println(conf)
|
// Pretty print the current config
|
||||||
|
str, _ := json.MarshalIndent(conf, "", " ")
|
||||||
|
fmt.Println(string(str))
|
||||||
|
|
||||||
database.DbConnect("db.sqlite3")
|
database.DbConnect(conf.DbPath)
|
||||||
b := &ButtonState{PressCount: 0}
|
b := &ButtonState{PressCount: 0}
|
||||||
|
|
||||||
// Mounting the handlers
|
// Mounting the handlers
|
||||||
|
@ -58,12 +60,14 @@ func main() {
|
||||||
http.HandleFunc("/hello", handler)
|
http.HandleFunc("/hello", handler)
|
||||||
http.HandleFunc("/api/button", b.pressHandler)
|
http.HandleFunc("/api/button", b.pressHandler)
|
||||||
|
|
||||||
// Start the server on port 8080
|
// Construct a server URL
|
||||||
println("Currently listening on http://localhost:8080")
|
server_url := fmt.Sprintf(":%d", conf.Port)
|
||||||
println("Visit http://localhost:8080/hello to see the hello handler in action")
|
|
||||||
println("Visit http://localhost:8080/button to see the button handler in action")
|
println("Server running on port", conf.Port)
|
||||||
|
println("Visit http://localhost" + server_url)
|
||||||
println("Press Ctrl+C to stop the server")
|
println("Press Ctrl+C to stop the server")
|
||||||
err = http.ListenAndServe(":8080", nil)
|
|
||||||
|
err = http.ListenAndServe(server_url, nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue