Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

https support #129

Closed
wants to merge 2 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion macaron.go
Original file line number Diff line number Diff line change
Expand Up @@ -235,25 +235,36 @@ func GetDefaultListenInfo() (string, int) {
// Run the http server. Listening on os.GetEnv("PORT") or 4000 by default.
func (m *Macaron) Run(args ...interface{}) {
host, port := GetDefaultListenInfo()
var fullchain, privateKey string
if len(args) == 1 {
switch arg := args[0].(type) {
case string:
host = arg
case int:
port = arg
}
} else if len(args) >= 2 {
} else if len(args) == 4 {
if arg, ok := args[0].(string); ok {
host = arg
}
if arg, ok := args[1].(int); ok {
port = arg
}
if arg, ok := args[2].(string); ok {
fullchain = arg
}
if arg, ok := args[3].(string); ok {
privateKey = arg
}
}

addr := host + ":" + com.ToStr(port)
logger := m.GetVal(reflect.TypeOf(m.logger)).Interface().(*log.Logger)
logger.Printf("listening on %s (%s)\n", addr, safeEnv())
if len(fullchain) > 5 {
logger.Fatalln(http.ListenAndServeTLS(addr, fullchain, privateKey, m))
return
}
logger.Fatalln(http.ListenAndServe(addr, m))
}

Expand Down