init
This commit is contained in:
commit
fa6a4c650f
93 files changed
+6555
No files matched your search
@@ -0,0 +1,96 @@
|
||||
package server
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
func (s *Server) handleRenamePathAPI(
|
||||
w http.ResponseWriter,
|
||||
r *http.Request,
|
||||
) {
|
||||
|
||||
var req struct {
|
||||
OldPath string `json:"old_path"`
|
||||
NewPath string `json:"new_path"`
|
||||
}
|
||||
|
||||
err := json.NewDecoder(
|
||||
r.Body,
|
||||
).Decode(&req)
|
||||
|
||||
if err != nil {
|
||||
|
||||
http.Error(
|
||||
w,
|
||||
err.Error(),
|
||||
400,
|
||||
)
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
err = s.store.RenamePath(
|
||||
req.OldPath,
|
||||
req.NewPath,
|
||||
)
|
||||
|
||||
if err != nil {
|
||||
|
||||
http.Error(
|
||||
w,
|
||||
err.Error(),
|
||||
500,
|
||||
)
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
w.WriteHeader(
|
||||
http.StatusNoContent,
|
||||
)
|
||||
}
|
||||
|
||||
func (s *Server) handleRemovePathAPI(
|
||||
w http.ResponseWriter,
|
||||
r *http.Request,
|
||||
) {
|
||||
|
||||
var req struct {
|
||||
Path string `json:"path"`
|
||||
}
|
||||
|
||||
err := json.NewDecoder(
|
||||
r.Body,
|
||||
).Decode(&req)
|
||||
|
||||
if err != nil {
|
||||
|
||||
http.Error(
|
||||
w,
|
||||
err.Error(),
|
||||
400,
|
||||
)
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
err = s.store.RemovePath(
|
||||
req.Path,
|
||||
)
|
||||
|
||||
if err != nil {
|
||||
|
||||
http.Error(
|
||||
w,
|
||||
err.Error(),
|
||||
500,
|
||||
)
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
w.WriteHeader(
|
||||
http.StatusNoContent,
|
||||
)
|
||||
}
|
||||
Reference in new issue
Block a user