mirror of
https://github.com/nicotsx/ironmount.git
synced 2025-12-10 12:10:51 +01:00
42 lines
719 B
Go
42 lines
719 B
Go
package driver
|
|
|
|
import (
|
|
"encoding/json"
|
|
"ironmount/internal/db"
|
|
"log"
|
|
"net/http"
|
|
)
|
|
|
|
func Get(w http.ResponseWriter, r *http.Request) {
|
|
log.Printf("Received get request: %s", r.URL.Path)
|
|
|
|
var req struct {
|
|
Name string
|
|
}
|
|
_ = json.NewDecoder(r.Body).Decode(&req)
|
|
|
|
vol, err := db.GetVolumeByName(req.Name)
|
|
|
|
if err != nil {
|
|
log.Printf("Error retrieving volume: %s", err.Error())
|
|
|
|
response := map[string]string{
|
|
"Err": err.Error(),
|
|
}
|
|
_ = json.NewEncoder(w).Encode(response)
|
|
|
|
return
|
|
}
|
|
|
|
response := map[string]any{
|
|
"Volume": map[string]any{
|
|
"Name": vol.Name,
|
|
"Mountpoint": vol.Path,
|
|
"Status": map[string]string{},
|
|
},
|
|
"Err": "",
|
|
}
|
|
|
|
_ = json.NewEncoder(w).Encode(response)
|
|
}
|