-
Notifications
You must be signed in to change notification settings - Fork 49
/
python3.go
32 lines (29 loc) · 990 Bytes
/
python3.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
package python3
import (
"net/http"
"time"
"github.com/yookoala/gofast"
)
// NewHandler returns a fastcgi web server implementation as an http.Handler
// Please note that this handler doesn't handle the fastcgi application process.
// You'd need to start it with other means.
//
// entrypoint: the full path to the application entrypoint file (e.g. webapp.py)
// or equivlant path for fastcgi application to identify itself.
// network: network protocol (tcp / tcp4 / tcp6)
// or if it is a unix socket, "unix"
// address: IP address and port, or the socket physical address of the fastcgi
// application.
func NewHandler(entrypoint, network, address string) http.Handler {
connFactory := gofast.SimpleConnFactory(network, address)
pool := gofast.NewClientPool(
gofast.SimpleClientFactory(connFactory),
10,
60*time.Second,
)
h := gofast.NewHandler(
gofast.NewFileEndpoint(entrypoint)(gofast.BasicSession),
pool.CreateClient,
)
return h
}