From 184426c35e20bf9901e11178d878add2491b89a2 Mon Sep 17 00:00:00 2001 From: Liang Ding Date: Sun, 22 Feb 2015 15:54:51 +0800 Subject: [PATCH] #212 parse request path --- playground/playgrounds.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/playground/playgrounds.go b/playground/playgrounds.go index dfd4375..cd0af41 100644 --- a/playground/playgrounds.go +++ b/playground/playgrounds.go @@ -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)