Skip to content

Commit

Permalink
Fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
cv65kr committed Nov 25, 2023
1 parent 69f8935 commit ad7af20
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 9 deletions.
22 changes: 14 additions & 8 deletions init.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
package http

import (
"net/http"

"github.com/roadrunner-server/http/v4/common"
bundledMw "github.com/roadrunner-server/http/v4/middleware"
"github.com/roadrunner-server/http/v4/servers/fcgi"
httpServer "github.com/roadrunner-server/http/v4/servers/http11"
http3Server "github.com/roadrunner-server/http/v4/servers/http3"
Expand Down Expand Up @@ -33,14 +36,17 @@ func (p *Plugin) initServers() error {
return nil
}

// func (p *Plugin) applyBundledMiddleware() {
// // apply max_req_size and logger middleware
// for i := 0; i < len(p.servers); i++ {
// serv := p.servers[i].Server()
// serv.Handler = bundledMw.MaxRequestSize(serv.Handler, p.cfg.MaxRequestSize*MB)
// serv.Handler = bundledMw.NewLogMiddleware(serv.Handler, p.cfg.AccessLogs, p.log)
// }
// }
func (p *Plugin) applyBundledMiddleware() {
// apply max_req_size and logger middleware
for i := 0; i < len(p.servers); i++ {
server := p.servers[i].Server()
if _, ok := server.(*http.Server); ok {
serv := server.(*http.Server)
serv.Handler = bundledMw.MaxRequestSize(serv.Handler, p.cfg.MaxRequestSize*MB)
serv.Handler = bundledMw.NewLogMiddleware(serv.Handler, p.cfg.AccessLogs, p.log)
}
}
}

func (p *Plugin) unmarshal(cfg common.Configurer) error {
// unmarshal general section
Expand Down
2 changes: 1 addition & 1 deletion plugin.go
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ func (p *Plugin) Serve() chan error {
}

// apply access_logs, max_request, redirect middleware if specified by user
//p.applyBundledMiddleware()
p.applyBundledMiddleware()

// start all servers
for i := 0; i < len(p.servers); i++ {
Expand Down

0 comments on commit ad7af20

Please sign in to comment.