All checks were successful
Pre Release Workflow / set-release-target (push) Successful in 1s
Pre Release Workflow / build (agent, amd64, linux) (push) Successful in 2m2s
Pre Release Workflow / build (db, amd64, linux) (push) Successful in 1m32s
Pre Release Workflow / build (dhcp, amd64, linux) (push) Successful in 1m32s
Pre Release Workflow / build (metadata, amd64, linux) (push) Successful in 1m33s
Pre Release Workflow / build (metacli, amd64, linux) (push) Successful in 1m40s
Pre Release Workflow / build (subnet, amd64, linux) (push) Successful in 1m37s
Pre Release Workflow / prerelease (push) Successful in 16s
Pre Release Workflow / build (vpc, amd64, linux) (push) Successful in 1m34s
Pre Release Workflow / upload-scripts (run-dnsmasq-in-netns.sh) (push) Successful in 7s
Signed-off-by: GnomeZworc <nicolas.boufidjeline@g3e.fr>
30 lines
658 B
Go
30 lines
658 B
Go
package agentapi
|
|
|
|
import (
|
|
"encoding/json"
|
|
"net/http"
|
|
"strings"
|
|
)
|
|
|
|
func (s *Server) VpcByNameHandler(w http.ResponseWriter, r *http.Request) {
|
|
name := strings.TrimPrefix(r.URL.Path, "/vpcs/")
|
|
if name == "" {
|
|
http.NotFound(w, r)
|
|
return
|
|
}
|
|
w.Header().Set("Content-Type", "application/json")
|
|
switch r.Method {
|
|
case http.MethodGet:
|
|
w.WriteHeader(http.StatusOK)
|
|
json.NewEncoder(w).Encode(map[string]string{"name": name})
|
|
case http.MethodDelete:
|
|
s.queue.Submit(func() {
|
|
deleteVpc(name)
|
|
})
|
|
w.WriteHeader(http.StatusAccepted)
|
|
default:
|
|
http.Error(w, "method not allowed", http.StatusMethodNotAllowed)
|
|
}
|
|
}
|
|
|
|
func deleteVpc(name string) {}
|