Don't require user to set YSV_HOST
The original reason for having this required configuration parameter was that I didn't think to read the hostname off the request. Doing it this way has the additional benefit of a single server being able to serve a multitude of hostnames. Derek helped me realize this by repeating "there should be sane defaults" like 9000 times (maybe over 9000) till I got so tired of trying to make sure that he understood why I did it that way to begin with that I looked at the problem from a different perspective and like in a dream the solution came to me. fixes #10.
This commit is contained in:
+1
-6
@@ -62,7 +62,6 @@ YSV_DB: path to json database
|
||||
|
||||
type config struct {
|
||||
Port int
|
||||
Host string
|
||||
DB string
|
||||
}
|
||||
|
||||
@@ -81,10 +80,6 @@ func main() {
|
||||
os.Exit(0)
|
||||
}
|
||||
}
|
||||
if c.Host == "" {
|
||||
log.Printf("must set YSV_HOST; please run $(ysvd env) for more information")
|
||||
os.Exit(1)
|
||||
}
|
||||
if c.DB == "" {
|
||||
log.Printf("warning: in-memory db mode; if you do not want this set YSV_DB")
|
||||
}
|
||||
@@ -100,7 +95,7 @@ func main() {
|
||||
if err := ms.Load(); err != nil {
|
||||
log.Printf("unable to load db: %v; creating fresh database", err)
|
||||
}
|
||||
vain.NewServer(sm, ms, c.Host)
|
||||
vain.NewServer(sm, ms)
|
||||
addr := fmt.Sprintf(":%d", c.Port)
|
||||
if err := http.ListenAndServe(addr, sm); err != nil {
|
||||
log.Printf("problem with http server: %v", err)
|
||||
|
||||
Reference in New Issue
Block a user