issue 43 "go fmt" chagnes from "Ryan S. Brown" <sb@ryansb.com>

some basic changes to parse upload url
This commit is contained in:
Chris Lu
2013-09-01 23:58:21 -07:00
parent 2e70cc8be7
commit 82b74c7940
28 changed files with 102 additions and 86 deletions

View File

@@ -7,7 +7,7 @@ import (
"fmt"
"io"
"math/rand"
"net"
"net"
"net/http"
"os"
"strings"
@@ -225,20 +225,20 @@ func debug(params ...interface{}) {
}
}
func secure(whiteList []string, f func(w http.ResponseWriter, r *http.Request)) func(w http.ResponseWriter, r *http.Request) {
return func(w http.ResponseWriter, r *http.Request) {
if len(whiteList) == 0 {
f(w, r)
return
}
host, _, err := net.SplitHostPort(r.RemoteAddr)
if err == nil {
for _, ip := range whiteList {
if ip == host {
f(w, r)
return
}
}
}
writeJsonQuiet(w, r, map[string]interface{}{"error": "No write permisson from " + host})
}
return func(w http.ResponseWriter, r *http.Request) {
if len(whiteList) == 0 {
f(w, r)
return
}
host, _, err := net.SplitHostPort(r.RemoteAddr)
if err == nil {
for _, ip := range whiteList {
if ip == host {
f(w, r)
return
}
}
}
writeJsonQuiet(w, r, map[string]interface{}{"error": "No write permisson from " + host})
}
}