Skip to content

Commit

Permalink
Merge pull request #717 from Fenny/master
Browse files Browse the repository at this point in the history
⚙ init on Handler call
  • Loading branch information
Fenny authored Aug 10, 2020
2 parents 0d31dc1 + cec3629 commit bfbb027
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions app.go
Original file line number Diff line number Diff line change
Expand Up @@ -439,7 +439,7 @@ func (app *App) Serve(ln net.Listener, tlsconfig ...*tls.Config) error {
// This method does not support the Prefork feature
// To use Prefork, please use app.Listen()
func (app *App) Listener(ln net.Listener, tlsconfig ...*tls.Config) error {
// Update fiber server settings
// Update server settings
app.init()
// TLS config
if len(tlsconfig) > 0 {
Expand Down Expand Up @@ -472,7 +472,7 @@ func (app *App) Listen(address interface{}, tlsconfig ...*tls.Config) error {
if !strings.Contains(addr, ":") {
addr = ":" + addr
}
// Update fiber server settings
// Update server settings
app.init()
// Start prefork
if app.Settings.Prefork {
Expand Down Expand Up @@ -502,6 +502,7 @@ func (app *App) Listen(address interface{}, tlsconfig ...*tls.Config) error {

// Handler returns the server handler.
func (app *App) Handler() fasthttp.RequestHandler {
app.init()
return app.handler
}

Expand Down Expand Up @@ -589,7 +590,10 @@ func (dl *disableLogger) Printf(format string, args ...interface{}) {
}

func (app *App) init() *App {
// Lock application
app.mutex.Lock()
defer app.mutex.Unlock()

// Load view engine if provided
if app.Settings != nil {
// Only load templates if an view engine is specified
Expand Down Expand Up @@ -636,7 +640,6 @@ func (app *App) init() *App {
app.server.ReadBufferSize = app.Settings.ReadBufferSize
app.server.WriteBufferSize = app.Settings.WriteBufferSize
app.buildTree()
app.mutex.Unlock()
return app
}

Expand Down

1 comment on commit bfbb027

@Fenny
Copy link
Member Author

@Fenny Fenny commented on bfbb027 Aug 14, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Performance Alert ⚠️

Possible performance regression was detected for benchmark.
Benchmark result of this commit is worse than the previous benchmark result exceeding threshold 2.

Benchmark suite Current: bfbb027 Previous: 0d31dc1 Ratio
Benchmark_Middleware_Compress 642 ns/op 176 B/op 2 allocs/op 261 ns/op 1 B/op 1 allocs/op 2.46
Benchmark_Middleware_Logger 1282 ns/op 279 B/op 3 allocs/op 256 ns/op 1 B/op 1 allocs/op 5.01

This comment was automatically generated by workflow using github-action-benchmark.

Please sign in to comment.