1
0
mirror of https://github.com/labstack/echo.git synced 2024-12-24 20:14:31 +02:00
Signed-off-by: Vishal Rana <vr@labstack.com>
This commit is contained in:
Vishal Rana 2017-05-12 10:38:02 -07:00
parent 10809fad77
commit 0e134ee37c

30
echo.go
View File

@ -74,6 +74,7 @@ type (
TLSListener net.Listener TLSListener net.Listener
DisableHTTP2 bool DisableHTTP2 bool
Debug bool Debug bool
HideBanner bool
HTTPErrorHandler HTTPErrorHandler HTTPErrorHandler HTTPErrorHandler
Binder Binder Binder Binder
Validator Validator Validator Validator
@ -204,6 +205,22 @@ const (
HeaderXCSRFToken = "X-CSRF-Token" HeaderXCSRFToken = "X-CSRF-Token"
) )
const (
version = "3.1.0"
website = "https://echo.labstack.com"
// http://patorjk.com/software/taag/#p=display&f=Small%20Slant&t=Echo
banner = `
____ __
/ __/___/ / ___
/ _// __/ _ \/ _ \
/___/\__/_//_/\___/ %s
High performance, minimalist Go web framework
%s
____________________________________O/_______
O\
`
)
var ( var (
methods = [...]string{ methods = [...]string{
CONNECT, CONNECT,
@ -581,6 +598,7 @@ func (e *Echo) startTLS(address string) error {
} }
// StartServer starts a custom http server. // StartServer starts a custom http server.
func (e *Echo) StartServer(s *http.Server) (err error) { func (e *Echo) StartServer(s *http.Server) (err error) {
// Setup // Setup
e.colorer.SetOutput(e.Logger.Output()) e.colorer.SetOutput(e.Logger.Output())
@ -590,6 +608,10 @@ func (e *Echo) StartServer(s *http.Server) (err error) {
e.Logger.SetLevel(log.DEBUG) e.Logger.SetLevel(log.DEBUG)
} }
if !e.HideBanner {
e.colorer.Printf(banner, e.colorer.Red("v"+version), e.colorer.Blue(website))
}
if s.TLSConfig == nil { if s.TLSConfig == nil {
if e.Listener == nil { if e.Listener == nil {
e.Listener, err = newListener(s.Addr) e.Listener, err = newListener(s.Addr)
@ -597,7 +619,9 @@ func (e *Echo) StartServer(s *http.Server) (err error) {
return err return err
} }
} }
e.colorer.Printf("⇛ http server started on %s\n", e.colorer.Green(e.Listener.Addr())) if !e.HideBanner {
e.colorer.Printf("🚀 http server started on %s\n", e.colorer.Green(e.Listener.Addr()))
}
return s.Serve(e.Listener) return s.Serve(e.Listener)
} }
if e.TLSListener == nil { if e.TLSListener == nil {
@ -607,7 +631,9 @@ func (e *Echo) StartServer(s *http.Server) (err error) {
} }
e.TLSListener = tls.NewListener(l, s.TLSConfig) e.TLSListener = tls.NewListener(l, s.TLSConfig)
} }
e.colorer.Printf("⇛ https server started on %s\n", e.colorer.Green(e.TLSListener.Addr())) if !e.HideBanner {
e.colorer.Printf("🚀 https server started on %s\n", e.colorer.Green(e.TLSListener.Addr()))
}
return s.Serve(e.TLSListener) return s.Serve(e.TLSListener)
} }