router.Run() can be called without parameters. #405

This commit is contained in:
Manu Mtz-Almeida
2015-08-16 16:19:51 +02:00
parent 2b3aa51738
commit ce2201c392
3 changed files with 76 additions and 20 deletions

View File

@ -7,6 +7,7 @@ package gin
import (
"encoding/xml"
"net/http"
"os"
"path"
"reflect"
"runtime"
@ -129,3 +130,20 @@ func joinPaths(absolutePath, relativePath string) string {
}
return finalPath
}
func resolveAddress(addr []string) string {
switch len(addr) {
case 0:
if port := os.Getenv("PORT"); len(port) > 0 {
debugPrint("Environment variable PORT=\"%s\"", port)
return ":" + port
} else {
debugPrint("Environment variable PORT is undefined. Using port :8080 by default")
return ":8080"
}
case 1:
return addr[0]
default:
panic("too much parameters")
}
}