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.