2016年9月30日 星期五

GO Web cgi server

package main

import(
  "net/http/cgi"
  "log"
  "net/http"
)

func main() {
  http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request){
    handler := new(cgi.Handler)
    handler.Path = "/root/goweb/" + r.URL.Path
//    handler.Dir = "/root/goweb/"

    log.Println(handler.Path)
    log.Println(handler.Args)

    handler.ServeHTTP(w, r)
  })

  log.Fatal(http.ListenAndServe(":8080",nil))
}

沒有留言: