33 lines
671 B
Go
33 lines
671 B
Go
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)
|
|
}
|