-
Notifications
You must be signed in to change notification settings - Fork 32
/
main.go
40 lines (32 loc) · 782 Bytes
/
main.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
33
34
35
36
37
38
39
40
package main
import (
"log"
"net"
"net/http"
"os"
"github.com/MagicalTux/goro/core/phpctx"
_ "github.com/MagicalTux/goro/ext/ctype"
_ "github.com/MagicalTux/goro/ext/date"
_ "github.com/MagicalTux/goro/ext/gmp"
_ "github.com/MagicalTux/goro/ext/hash"
_ "github.com/MagicalTux/goro/ext/json"
_ "github.com/MagicalTux/goro/ext/pcre"
_ "github.com/MagicalTux/goro/ext/standard"
)
func main() {
p := phpctx.NewProcess("httpd")
p.CommandLine(os.Args)
l, err := net.Listen("tcp", ":8080")
if err != nil {
log.Fatalf("failed to listen: %s", err)
}
log.Printf("[php-httpd] Listening on %s", l.Addr())
path := "."
if len(os.Args) == 2 {
path = os.Args[1]
}
err = http.Serve(l, p.Handler(path))
if err != nil {
log.Fatalf("failed to serve: %s", err)
}
}