Add 'port' configuration option (fix #7)
This commit is contained in:
parent
cc458e6381
commit
260df0914a
@ -9,6 +9,7 @@ import (
|
|||||||
|
|
||||||
// Configuration stores information retrieved from a configuration file
|
// Configuration stores information retrieved from a configuration file
|
||||||
type Configuration struct {
|
type Configuration struct {
|
||||||
|
port int
|
||||||
sites_dir string
|
sites_dir string
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -21,6 +22,7 @@ func parseConfig(path string, config *Configuration) {
|
|||||||
log.Panic("Failed to parse config:", err)
|
log.Panic("Failed to parse config:", err)
|
||||||
}
|
}
|
||||||
file.Close()
|
file.Close()
|
||||||
|
config.port = int(data["port"].(float64)) // this conversion makes no sense
|
||||||
config.sites_dir = data["sites_dir"].(string)
|
config.sites_dir = data["sites_dir"].(string)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
{
|
{
|
||||||
|
"port": 7575,
|
||||||
"sites_dir": "./sites"
|
"sites_dir": "./sites"
|
||||||
}
|
}
|
||||||
|
4
main.go
4
main.go
@ -60,6 +60,6 @@ func main() {
|
|||||||
go handler(data) // Run the handler
|
go handler(data) // Run the handler
|
||||||
fmt.Fprint(w, "Received!")
|
fmt.Fprint(w, "Received!")
|
||||||
})
|
})
|
||||||
log.Printf("Starting Lapis Deploy...")
|
log.Printf("Starting Lapis Deploy on port %d...", configuration.port)
|
||||||
log.Fatal(http.ListenAndServe(":7575", nil))
|
log.Fatal(http.ListenAndServe(fmt.Sprintf(":%d", configuration.port), nil))
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user