Change DisableStartupMessage behavior

pull/425/head
Juan Riquelme González 2020-05-30 17:39:33 +02:00
parent d247e2a961
commit 5babf5a055
1 changed files with 10 additions and 27 deletions

37
app.go
View File

@ -28,9 +28,7 @@ import (
// Version of current package
const Version = "1.10.1"
var fiberASCIIBanner = fmt.Sprintf(" _______ __\n ____ / ____(_) /_ ___ _____\n_____ / /_ / / __ \\/ _ \\/ ___/\n __ / __/ / / /_/ / __/ /\n /_/ /_/_.___/\\___/_/ v%s\n", Version)
// Map is a shortcut for map[string]interface{}, usefull for JSON returns
// Map is a shortcut for map[string]interface{}, useful for JSON returns
type Map map[string]interface{}
// Handler ...
@ -93,13 +91,7 @@ type Settings struct {
// By default all header names are normalized: conteNT-tYPE -> Content-Type
DisableHeaderNormalizing bool // default: false
// Startup banner
StartupBanner string // default: fiberASCIIBanner
// When set to true, it will hide the startup banner
HideStartupBanner bool // default: false
// When set to true, it will not print out the StartupBanner and "listening" on message
// When set to true, it will not print out the «Fiber» ASCII art
DisableStartupMessage bool // default: false
// Templates is the interface that wraps the Render function.
@ -174,10 +166,9 @@ func New(settings ...*Settings) *App {
},
// Set default settings
Settings: &Settings{
Prefork: utils.GetArgument("-prefork"),
BodyLimit: 4 * 1024 * 1024,
Concurrency: 256 * 1024,
StartupBanner: fiberASCIIBanner,
Prefork: utils.GetArgument("-prefork"),
BodyLimit: 4 * 1024 * 1024,
Concurrency: 256 * 1024,
},
}
// Overwrite settings if provided
@ -197,9 +188,6 @@ func New(settings ...*Settings) *App {
getBytes = getBytesImmutable
getString = getStringImmutable
}
if app.Settings.StartupBanner == "" {
app.Settings.StartupBanner = fiberASCIIBanner
}
}
// Initialize app
return app.init()
@ -314,11 +302,9 @@ func (app *App) Serve(ln net.Listener, tlsconfig ...*tls.Config) error {
}
// Print startup message
if !app.Settings.DisableStartupMessage {
if !app.Settings.HideStartupBanner {
fmt.Print(app.Settings.StartupBanner)
}
fmt.Printf("Started listening on %s\n", ln.Addr().String())
fmt.Printf(" _______ __\n ____ / ____(_) /_ ___ _____\n_____ / /_ / / __ \\/ _ \\/ ___/\n __ / __/ / / /_/ / __/ /\n /_/ /_/_.___/\\___/_/ v%s\n", Version)
}
fmt.Printf("Started listening on %s\n", ln.Addr().String())
return app.server.Serve(ln)
}
@ -357,13 +343,10 @@ func (app *App) Listen(address interface{}, tlsconfig ...*tls.Config) error {
}
// Print startup message
if !app.Settings.DisableStartupMessage && !utils.GetArgument("-child") {
if !app.Settings.HideStartupBanner {
if !app.Settings.HideStartupBanner {
fmt.Print(app.Settings.StartupBanner)
}
}
fmt.Printf("Started listening on %s\n", ln.Addr().String())
fmt.Printf(" _______ __\n ____ / ____(_) /_ ___ _____\n_____ / /_ / / __ \\/ _ \\/ ___/\n __ / __/ / / /_/ / __/ /\n /_/ /_/_.___/\\___/_/ v%s\n", Version)
}
fmt.Printf("Started listening on %s\n", ln.Addr().String())
return app.server.Serve(ln)
}