1
0

Made use of my own httpr router. Replace GetURLParam with httpr.Param.

This commit is contained in:
Alexander Andreev 2023-05-26 04:28:38 +04:00
parent 0677147b63
commit b18338e4e1
Signed by: Arav
GPG Key ID: D22A817D95815393

View File

@ -15,6 +15,8 @@ import (
"path"
"strings"
"time"
"git.arav.su/Arav/httpr"
)
type UploadHandlers struct {
@ -159,7 +161,7 @@ func (h *UploadHandlers) Upload(w http.ResponseWriter, r *http.Request) {
}
func (h *UploadHandlers) Download(w http.ResponseWriter, r *http.Request) {
saltedHash := GetURLParam(r, "hash")
saltedHash := httpr.Param(r, "hash")
path := path.Join(h.uploadDir, saltedHash)
@ -169,7 +171,7 @@ func (h *UploadHandlers) Download(w http.ResponseWriter, r *http.Request) {
return
}
name := GetURLParam(r, "name")
name := httpr.Param(r, "name")
w.Header().Add("Content-Disposition", fmt.Sprintf("attachment; filename=\"%s\"", name))
@ -191,7 +193,7 @@ func (h *UploadHandlers) Download(w http.ResponseWriter, r *http.Request) {
func (h *UploadHandlers) Delete(w http.ResponseWriter, r *http.Request) {
var saltedHash string
if r.Method == "DELETE" {
saltedHash = GetURLParam(r, "hash")
saltedHash = httpr.Param(r, "hash")
} else {
r.ParseForm()
saltedHash = r.FormValue("hash")