mirror of
https://github.com/chubin/wttr.in
synced 2025-01-12 03:58:45 +00:00
Move server config to Config struct
This commit is contained in:
parent
7d801e3b4d
commit
5bb0c4f1fe
3 changed files with 19 additions and 2 deletions
|
@ -3,6 +3,7 @@ package main
|
|||
// Config of the program.
|
||||
type Config struct {
|
||||
Logging
|
||||
Server
|
||||
}
|
||||
|
||||
// Logging configuration.
|
||||
|
@ -15,10 +16,26 @@ type Logging struct {
|
|||
Interval int
|
||||
}
|
||||
|
||||
// Server configuration.
|
||||
type Server struct {
|
||||
|
||||
// PortHTTP is port where HTTP server must listen.
|
||||
// If 0, HTTP is disabled.
|
||||
PortHTTP int
|
||||
|
||||
// PortHTTP is port where the HTTPS server must listen.
|
||||
// If 0, HTTPS is disabled.
|
||||
PortHTTPS int
|
||||
}
|
||||
|
||||
// Conf contains the current configuration.
|
||||
var Conf = Config{
|
||||
Logging{
|
||||
AccessLog: "/wttr.in/log/access.log",
|
||||
Interval: 300,
|
||||
},
|
||||
Server{
|
||||
PortHTTP: 8083,
|
||||
PortHTTPS: 0,
|
||||
},
|
||||
}
|
||||
|
|
|
@ -95,6 +95,7 @@ func (rl *RequestLogger) flush() error {
|
|||
return nil
|
||||
}
|
||||
|
||||
// String returns string representation of logEntry.
|
||||
func (e *logEntry) String() string {
|
||||
return fmt.Sprintf(
|
||||
"%s %s %s %s",
|
||||
|
|
|
@ -11,7 +11,6 @@ import (
|
|||
lru "github.com/hashicorp/golang-lru"
|
||||
)
|
||||
|
||||
const serverPort = 8083
|
||||
const uplinkSrvAddr = "127.0.0.1:9002"
|
||||
const uplinkTimeout = 30
|
||||
const prefetchInterval = 300
|
||||
|
@ -90,5 +89,5 @@ func main() {
|
|||
w.Write(response.Body)
|
||||
})
|
||||
|
||||
log.Fatal(http.ListenAndServe(fmt.Sprintf(":%d", serverPort), nil))
|
||||
log.Fatal(http.ListenAndServe(fmt.Sprintf(":%d", Conf.Server.PortHTTP), nil))
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue