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
|
package main
import (
"flag"
"log"
"net/http"
"net/http/cgi"
"strings"
)
func main() {
path := flag.String("path", "", "Path to the cgi binary")
dir := flag.String("dir", "", "set a different working directory from the base path of 'path'")
env := flag.String("env", "", "set environment variables for the CGI process")
prefix := flag.String("uri-prefix", "/", "set the URL prefix when the CGI process is hosted in a sub directory")
flag.Parse()
forwarder := &cgi.Handler{
Path: *path,
Root: *prefix,
Env: strings.Split(*env, ","),
Dir: *dir,
}
http.Handle("/", forwarder)
log.Fatalf("server stopped working: %s", http.ListenAndServe(":8080", nil))
}
|