1
0
mirror of https://github.com/labstack/echo.git synced 2024-12-24 20:14:31 +02:00

Merge pull request #17 from dlsniper/configurable-server

Introduce the ability to run configurable and TLS enabled servers
This commit is contained in:
Vishal Rana 2015-04-03 07:55:25 -07:00
commit 05d52420be

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) {