-
Notifications
You must be signed in to change notification settings - Fork 18
/
Copy pathserver.go
37 lines (30 loc) · 1.39 KB
/
server.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
package api
import (
"net/http"
"github.com/gorilla/mux"
)
func Handler() http.Handler {
r := mux.NewRouter()
// machines
r.HandleFunc("/api/machines", ListMachinesHandler).Methods("GET")
r.HandleFunc("/api/machines", CreateMachineHandler).Methods("POST")
r.HandleFunc("/api/machines/{name}", GetMachineHandler).Methods("GET")
r.HandleFunc("/api/machines/{name}", UpdateMachineHandler).Methods("PUT")
r.HandleFunc("/api/machines/{name}", DeleteMachineHandler).Methods("DELETE")
// profiles
r.HandleFunc("/api/profiles", ListProfilesHandler).Methods("GET")
r.HandleFunc("/api/profiles", CreateProfileHandler).Methods("POST")
r.HandleFunc("/api/profiles/{name}", GetProfileHandler).Methods("GET")
r.HandleFunc("/api/profiles/{name}", DeleteProfileHandler).Methods("DELETE")
// sshkeys
r.HandleFunc("/api/sshkeys", ListSSHKeyHandler).Methods("GET")
r.HandleFunc("/api/sshkeys", CreateSSHKeyHandler).Methods("POST")
r.HandleFunc("/api/sshkeys/{name}", GetSSHKeyHandler).Methods("GET")
r.HandleFunc("/api/sshkeys/{name}", DeleteSSHKeyHandler).Methods("DELETE")
// cloudconfigs
r.HandleFunc("/api/cloudconfigs", ListCloudConfigHandler).Methods("GET")
r.HandleFunc("/api/cloudconfigs", CreateCloudConfigHandler).Methods("POST")
r.HandleFunc("/api/cloudconfigs/{name}", GetCloudConfigHandler).Methods("GET")
r.HandleFunc("/api/cloudconfigs/{name}", DeleteCloudConfigHandler).Methods("DELETE")
return r
}