chore(repo): reinitialize repository
This commit is contained in:
@@ -0,0 +1,34 @@
|
||||
package httpapi
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"inbox/internal/base/httpx"
|
||||
)
|
||||
|
||||
func (h *Handler) listDirectories(w http.ResponseWriter, r *http.Request) {
|
||||
listing, err := h.SystemFS.ListDirectories(r.URL.Query().Get("path"))
|
||||
if err != nil {
|
||||
writeSystemFSError(w, err)
|
||||
return
|
||||
}
|
||||
httpx.WriteJSON(w, http.StatusOK, listing)
|
||||
}
|
||||
|
||||
func (h *Handler) createDirectory(w http.ResponseWriter, r *http.Request) {
|
||||
type request struct {
|
||||
Parent string `json:"parent"`
|
||||
Name string `json:"name"`
|
||||
}
|
||||
var req request
|
||||
if err := httpx.DecodeJSON(r, &req); err != nil {
|
||||
httpx.WriteError(w, http.StatusBadRequest, err.Error())
|
||||
return
|
||||
}
|
||||
path, err := h.SystemFS.CreateDirectory(req.Parent, req.Name)
|
||||
if err != nil {
|
||||
writeSystemFSError(w, err)
|
||||
return
|
||||
}
|
||||
httpx.WriteJSON(w, http.StatusCreated, map[string]any{"path": path})
|
||||
}
|
||||
Reference in New Issue
Block a user