diff options
Diffstat (limited to 'backend/api/routes.go')
| -rw-r--r-- | backend/api/routes.go | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/backend/api/routes.go b/backend/api/routes.go index 7fb2114..f8d2e4f 100644 --- a/backend/api/routes.go +++ b/backend/api/routes.go @@ -51,13 +51,26 @@ func insertFunc(w http.ResponseWriter, r *http.Request) { fmt.Fprintf(w, "%+v", string(jsonData)) } -func getHashFunc(w http.ResponseWriter, r *http.Request) { +func getPasteFunc(w http.ResponseWriter, r *http.Request) { + // no password given for get + handleGetPaste(w, r, "") +} + +func getPasteWithPasswordFunc(w http.ResponseWriter, r *http.Request) { + // get password from form + _ = r.ParseMultipartForm(0) + parsedPassword := r.FormValue("password") + + handleGetPaste(w, r, parsedPassword) + +} +func handleGetPaste(w http.ResponseWriter, r *http.Request, parsedPassword string) { // Allow CORS w.Header().Set("Access-Control-Allow-Origin", "*") hash := mux.Vars(r)["hash"] - paste, err := cache.C.Get(hash) + paste, err := cache.C.Get(hash, parsedPassword) // if hash was not found if err == cache.PasteNotFound { |