mirror of
https://github.com/labstack/echo.git
synced 2024-12-24 20:14:31 +02:00
dummy
Signed-off-by: Vishal Rana <vr@labstack.com>
This commit is contained in:
parent
bf239af966
commit
7cf31b3b68
@ -5,8 +5,9 @@ import (
|
||||
"mime/multipart"
|
||||
"time"
|
||||
|
||||
"github.com/labstack/gommon/log"
|
||||
"net"
|
||||
|
||||
"github.com/labstack/gommon/log"
|
||||
)
|
||||
|
||||
type (
|
||||
@ -138,7 +139,7 @@ type (
|
||||
// Config defines engine configuration.
|
||||
Config struct {
|
||||
Address string // TCP address to listen on.
|
||||
Listener net.Listener // Custom net.Listener for the HTTP server.
|
||||
Listener net.Listener // Custom `net.Listener`. If set, server accepts connections on it.
|
||||
TLSCertfile string // TLS certificate file path.
|
||||
TLSKeyfile string // TLS key file path.
|
||||
ReadTimeout time.Duration // Maximum duration before timing out read of the request.
|
||||
|
@ -124,26 +124,26 @@ func (s *Server) Start() {
|
||||
certfile := s.config.TLSCertfile
|
||||
keyfile := s.config.TLSKeyfile
|
||||
|
||||
if nil == s.config.Listener {
|
||||
if s.config.Listener == nil {
|
||||
s.startDefaultListener(addr, certfile, keyfile, handler)
|
||||
} else {
|
||||
s.startCustomListener(certfile, keyfile, handler)
|
||||
}
|
||||
}
|
||||
|
||||
func (s *Server) startDefaultListener(addr, certfile, keyfile string, handler func(c *fasthttp.RequestCtx)) {
|
||||
func (s *Server) startDefaultListener(addr, certfile, keyfile string, h fasthttp.RequestHandler) {
|
||||
if certfile != "" && keyfile != "" {
|
||||
s.logger.Fatal(fasthttp.ListenAndServeTLS(addr, certfile, keyfile, handler))
|
||||
s.logger.Fatal(fasthttp.ListenAndServeTLS(addr, certfile, keyfile, h))
|
||||
} else {
|
||||
s.logger.Fatal(fasthttp.ListenAndServe(addr, handler))
|
||||
s.logger.Fatal(fasthttp.ListenAndServe(addr, h))
|
||||
}
|
||||
}
|
||||
|
||||
func (s *Server) startCustomListener(certfile, keyfile string, handler func(c *fasthttp.RequestCtx)) {
|
||||
func (s *Server) startCustomListener(certfile, keyfile string, h fasthttp.RequestHandler) {
|
||||
if certfile != "" && keyfile != "" {
|
||||
s.logger.Fatal(fasthttp.ServeTLS(s.config.Listener, certfile, keyfile, handler))
|
||||
s.logger.Fatal(fasthttp.ServeTLS(s.config.Listener, certfile, keyfile, h))
|
||||
} else {
|
||||
s.logger.Fatal(fasthttp.Serve(s.config.Listener, handler))
|
||||
s.logger.Fatal(fasthttp.Serve(s.config.Listener, h))
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -95,7 +95,7 @@ func (s *Server) Start() {
|
||||
certfile := s.config.TLSCertfile
|
||||
keyfile := s.config.TLSKeyfile
|
||||
|
||||
if nil == s.config.Listener {
|
||||
if s.config.Listener == nil {
|
||||
s.startDefaultListener(certfile, keyfile)
|
||||
} else {
|
||||
s.startCustomListener()
|
||||
|
@ -575,6 +575,7 @@ func TestRouterAPI(t *testing.T) {
|
||||
func BenchmarkRouterGitHubAPI(b *testing.B) {
|
||||
e := New()
|
||||
r := e.router
|
||||
b.ReportAllocs()
|
||||
|
||||
// Add routes
|
||||
for _, route := range api {
|
||||
@ -584,10 +585,14 @@ func BenchmarkRouterGitHubAPI(b *testing.B) {
|
||||
}
|
||||
|
||||
// Find routes
|
||||
c := e.pool.Get().(*context)
|
||||
for i := 0; i < b.N; i++ {
|
||||
for _, route := range api {
|
||||
// c := e.pool.Get().(*context)
|
||||
c := e.GetContext()
|
||||
r.Find(route.Method, route.Path, c)
|
||||
// router.Find(r.Method, r.Path, c)
|
||||
e.PutContext(c)
|
||||
// e.pool.Put(c)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user