aboutsummaryrefslogtreecommitdiff
path: root/main.go
diff options
context:
space:
mode:
Diffstat (limited to 'main.go')
-rw-r--r--main.go12
1 files changed, 11 insertions, 1 deletions
diff --git a/main.go b/main.go
index f48b6bf..007a083 100644
--- a/main.go
+++ b/main.go
@@ -31,10 +31,20 @@ func randName(n int) string {
31 return string(b) 31 return string(b)
32} 32}
33 33
34func getKey(r *http.Request) string {
35 var key string
36 header := r.Header.Get("Authorization")
37 key = strings.Split(header, " ")[1]
38 if key == "" {
39 key = r.FormValue("key")
40 }
41 return key
42}
43
34func (s *settings) uploadFile(w http.ResponseWriter, r *http.Request) { 44func (s *settings) uploadFile(w http.ResponseWriter, r *http.Request) {
35 switch r.Method { 45 switch r.Method {
36 case "POST": 46 case "POST":
37 key := r.FormValue("key") 47 key := getKey(r)
38 useragent := r.Header.Get("User-Agent") 48 useragent := r.Header.Get("User-Agent")
39 if key != s.key { 49 if key != s.key {
40 fmt.Fprintf(w, "incorrect key") 50 fmt.Fprintf(w, "incorrect key")