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

25
api/router/router.go Normal file
View File

@@ -0,0 +1,25 @@
package router
import (
"net/http"
"vm-ctp/api/resource/common"
"vm-ctp/api/resource/vm"
"github.com/gorilla/mux"
)
func New() *mux.Router {
r := mux.NewRouter()
// If nothing more specific is requested then just display some version information
r.HandleFunc("/", common.HomeLink)
s := r.PathPrefix("/api").Subrouter()
s.HandleFunc("/event/vm/create", vm.VmCreateHandler).Methods("POST") // receive VM creation event from Direktiv
s.HandleFunc("/event/vm/remove", vm.VmRemoveHandler).Methods("POST") // receive VM creation event from Direktiv
// Not found handler
r.NotFoundHandler = http.HandlerFunc(common.HandleNotFound)
return r
}