mirror of
				https://github.com/labstack/echo.git
				synced 2025-10-30 23:57:38 +02:00 
			
		
		
		
	Introduce the ability to run configurable and TLS enabled servers
This commit is contained in:
		
							
								
								
									
										18
									
								
								echo.go
									
									
									
									
									
								
							
							
						
						
									
										18
									
								
								echo.go
									
									
									
									
									
								
							| @@ -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) { | ||||
|   | ||||
		Reference in New Issue
	
	Block a user