more file structure

This commit is contained in:
2024-09-11 21:24:34 +10:00
parent a5196bb321
commit 88c9cb3eef
17 changed files with 649 additions and 40 deletions

View File

@@ -0,0 +1,32 @@
package vm
import (
"fmt"
"io"
"log/slog"
"net/http"
"github.com/gorilla/mux"
)
// TODO godoc
func VmCreateHandler(w http.ResponseWriter, r *http.Request) {
reqBody, err := io.ReadAll(r.Body)
if err != nil {
fmt.Fprintf(w, "Invalid data received")
w.WriteHeader(http.StatusInternalServerError)
return
}
slog.Debug("received create request", "body", string(reqBody))
w.WriteHeader(http.StatusOK)
fmt.Fprintf(w, "Create Request (%d): %v\n", len(reqBody), string(reqBody))
}
// TODO godoc
func VmRemoveHandler(w http.ResponseWriter, r *http.Request) {
vars := mux.Vars(r)
w.WriteHeader(http.StatusOK)
fmt.Fprintf(w, "Remove Request: %v\n", vars)
}