router.Run() can be called without parameters. #405
This commit is contained in:
18
utils.go
18
utils.go
@ -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")
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user