1
0
mirror of https://github.com/labstack/echo.git synced 2024-11-28 08:38:39 +02:00

Introduce the ability to run configurable and TLS enabled servers

This commit is contained in:
Florin Patan 2015-04-03 14:24:47 +02:00
parent ab807fe8e5
commit 94356721c8

18
echo.go
View File

@ -225,10 +225,28 @@ func (e *Echo) ServeHTTP(rw http.ResponseWriter, r *http.Request) {
e.pool.Put(c)
}
// Run a server
func (e *Echo) Run(addr string) {
log.Fatal(http.ListenAndServe(addr, e))
}
// RunTLS a server
func (e *Echo) RunTLS(addr, certFile, keyFile string) {
log.Fatal(http.ListenAndServeTLS(addr, certFile, keyFile, e))
}
// RunServer runs a custom server
func (e *Echo) RunServer(server *http.Server) {
server.Handler = e
log.Fatal(server.ListenAndServe())
}
// RunTLSServer runs a custom server with TLS configuration
func (e *Echo) RunTLSServer(server *http.Server, certFile, keyFile string) {
server.Handler = e
log.Fatal(server.ListenAndServeTLS(certFile, keyFile))
}
// wraps Middleware
func wrapM(m Middleware) MiddlewareFunc {
switch m := m.(type) {