26 lines
655 B
Go
26 lines
655 B
Go
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
|
|
}
|