parse request path
This commit is contained in:
Liang Ding 2015-02-22 15:54:51 +08:00
parent 3b8cb3385b
commit 184426c35e
1 changed files with 3 additions and 2 deletions

View File

@ -64,8 +64,9 @@ func IndexHandler(w http.ResponseWriter, r *http.Request) {
// try to load file
code := conf.HelloWorld
fileName := "8b7cc38b4c12e6fde5c4d15a4f2f32e5.go" // MD5 of HelloWorld.go
if strings.HasSuffix(r.RequestURI, ".go") {
fileNameArg := r.RequestURI[len("/playground/"):]
if strings.HasSuffix(r.URL.Path, ".go") {
fileNameArg := r.URL.Path[len("/playground/"):]
filePath := filepath.Clean(conf.Wide.Playground + "/" + fileNameArg)
bytes, err := ioutil.ReadFile(filePath)