simplify some httpd related code

and update chi, cobra and viper
This commit is contained in:
Nicola Murino
2020-04-21 19:24:38 +02:00
parent 9248c5a987
commit 4f668bf558
4 changed files with 37 additions and 80 deletions

View File

@@ -17,6 +17,7 @@ import (
"github.com/drakkan/sftpgo/sftpd"
"github.com/drakkan/sftpgo/utils"
"github.com/drakkan/sftpgo/vfs"
"github.com/go-chi/chi"
)
const (
@@ -478,8 +479,8 @@ func handleWebAddUserGet(w http.ResponseWriter, r *http.Request) {
renderAddUserPage(w, dataprovider.User{Status: 1}, "")
}
func handleWebUpdateUserGet(userID string, w http.ResponseWriter, r *http.Request) {
id, err := strconv.ParseInt(userID, 10, 64)
func handleWebUpdateUserGet(w http.ResponseWriter, r *http.Request) {
id, err := strconv.ParseInt(chi.URLParam(r, "userID"), 10, 64)
if err != nil {
renderBadRequestPage(w, err)
return
@@ -509,9 +510,9 @@ func handleWebAddUserPost(w http.ResponseWriter, r *http.Request) {
}
}
func handleWebUpdateUserPost(userID string, w http.ResponseWriter, r *http.Request) {
func handleWebUpdateUserPost(w http.ResponseWriter, r *http.Request) {
r.Body = http.MaxBytesReader(w, r.Body, maxRequestSize)
id, err := strconv.ParseInt(userID, 10, 64)
id, err := strconv.ParseInt(chi.URLParam(r, "userID"), 10, 64)
if err != nil {
renderBadRequestPage(w, err)
return