Add support for FCGI via net/http/fcgi

This commit is contained in:
Thomas Godart 2020-07-22 12:39:57 +02:00
parent 4cabdd303f
commit ab554d7a93
1 changed files with 11 additions and 0 deletions

11
gin.go
View File

@ -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.