Using revel framework (golang), how can I get port I set in app.conf?
// in app.conf
http.port=9090
And I have to use my server's port number in controllers (for example OAuth coding) such as
requestToken, url, err := TWITTER.GetRequestTokenAndUrl(
"http://127.0.0.1:9090/Application/Authenticate",
)
I don't want to write port number by hard coding. Using revel, is there any good way to get port number (or any other conf values) set in app.conf?
Thank you in advance
May be this documentation will be useful - http://robfig.github.io/revel/docs/godoc/config.html
For example
// Load app.conf
var err error
Config, err = LoadConfig("app.conf")
if err != nil || Config == nil {
log.Fatalln("Failed to load app.conf:", err)
}
HttpPort = Config.IntDefault("http.port", 9000)
An another approach may be used instead direct loading (see modules/db/app/db.go)
import (
"github.com/robfig/revel"
)
if option, found = revel.Config.String("option"); !found {
revel.ERROR.Fatal("No option found.")
}