From ab554d7a936ea4fc6fe5d247b59c88953b120cad Mon Sep 17 00:00:00 2001 From: Thomas Godart Date: Wed, 22 Jul 2020 12:39:57 +0200 Subject: [PATCH] Add support for FCGI via net/http/fcgi --- gin.go | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/gin.go b/gin.go index 1e126179..0ca34317 100644 --- a/gin.go +++ b/gin.go @@ -9,6 +9,7 @@ import ( "html/template" "net" "net/http" + "net/http/fcgi" "os" "path" "sync" @@ -311,6 +312,16 @@ func (engine *Engine) Run(addr ...string) (err error) { return } +// RunFCGI attaches the router to a fcgi.child and starts listening to os.Stdin for requests +// It is a shortcut for fcgi.Serve(nil, router) +func (engine *Engine) RunFCGI() (err error) { + defer func() { debugPrintError(err) }() + + debugPrint("Listening and serving HTTP on FCGI\n") + err = fcgi.Serve(nil, engine) + return +} + // RunTLS attaches the router to a http.Server and starts listening and serving HTTPS (secure) requests. // It is a shortcut for http.ListenAndServeTLS(addr, certFile, keyFile, router) // Note: this method will block the calling goroutine indefinitely unless an error happens.