mirror of
https://github.com/gin-gonic/gin.git
synced 2025-10-18 06:42:10 +08:00
default gin run address
This commit is contained in:
parent
f8576af1f9
commit
3863064235
7
utils.go
7
utils.go
@ -17,6 +17,9 @@ import (
|
|||||||
// BindKey indicates a default bind key.
|
// BindKey indicates a default bind key.
|
||||||
const BindKey = "_gin-gonic/gin/bindkey"
|
const BindKey = "_gin-gonic/gin/bindkey"
|
||||||
|
|
||||||
|
// DefaultRunAddress default gin run address.
|
||||||
|
var DefaultRunAddress = ":8080"
|
||||||
|
|
||||||
// Bind is a helper function for given interface object and returns a Gin middleware.
|
// Bind is a helper function for given interface object and returns a Gin middleware.
|
||||||
func Bind(val interface{}) HandlerFunc {
|
func Bind(val interface{}) HandlerFunc {
|
||||||
value := reflect.ValueOf(val)
|
value := reflect.ValueOf(val)
|
||||||
@ -143,8 +146,8 @@ func resolveAddress(addr []string) string {
|
|||||||
debugPrint("Environment variable PORT=\"%s\"", port)
|
debugPrint("Environment variable PORT=\"%s\"", port)
|
||||||
return ":" + port
|
return ":" + port
|
||||||
}
|
}
|
||||||
debugPrint("Environment variable PORT is undefined. Using port :8080 by default")
|
debugPrint("Environment variable PORT is undefined. Using address:%s by default", DefaultRunAddress)
|
||||||
return ":8080"
|
return DefaultRunAddress
|
||||||
case 1:
|
case 1:
|
||||||
return addr[0]
|
return addr[0]
|
||||||
default:
|
default:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user