no listing without apikey
All checks were successful
Build and Publish / BuildAndDeploy (push) Successful in 39s
All checks were successful
Build and Publish / BuildAndDeploy (push) Successful in 39s
This commit is contained in:
9
main.go
9
main.go
@@ -158,7 +158,7 @@ func main() {
|
||||
mux := http.NewServeMux()
|
||||
mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
|
||||
pth, fileName := GetPathAndFileFromUrl(r.URL)
|
||||
log.Printf("Request path parts: %+v, fileName:%s", pth, fileName)
|
||||
log.Printf("Request: %+v, fileName:%s, method: %s", pth, fileName, r.Method)
|
||||
folder, err := app.GetOrSpawn(pth)
|
||||
if err != nil {
|
||||
if err != nil {
|
||||
@@ -167,8 +167,12 @@ func main() {
|
||||
return
|
||||
}
|
||||
}
|
||||
log.Printf("Retrieved folder: %+v, exists: %v", folder)
|
||||
if fileName == "" {
|
||||
authKey := r.Header.Get("Authorization")
|
||||
if authKey != apiKey {
|
||||
w.WriteHeader(http.StatusUnauthorized)
|
||||
return
|
||||
}
|
||||
content, err := folder.Storage.List("")
|
||||
if err != nil {
|
||||
w.WriteHeader(http.StatusInternalServerError)
|
||||
@@ -200,6 +204,7 @@ func main() {
|
||||
if err != nil {
|
||||
w.WriteHeader(http.StatusInternalServerError)
|
||||
w.Write([]byte(err.Error()))
|
||||
return
|
||||
}
|
||||
folder.Storage.Put(fileName, data)
|
||||
w.WriteHeader(http.StatusCreated)
|
||||
|
||||
Reference in New Issue
Block a user