aboutsummaryrefslogtreecommitdiffstats
path: root/internal/api/routes/routes.go
blob: e35c5a8e02865f3f3479edf664e0a793416d507c (plain) (blame)
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
38
39
40
41
42
43
44
45
package routes

import (
	"net/http"

	h "synf/internal/api/data/rest"

	"github.com/gorilla/mux"
	"github.com/gorilla/websocket"
)

var upgrader = websocket.Upgrader{
	ReadBufferSize:    1024,
	WriteBufferSize:   1024,
	EnableCompression: true,
	CheckOrigin: func(r *http.Request) bool {
		return true
	},
}

func InitRestRoutes() *mux.Router {
	r := mux.NewRouter()

	r.HandleFunc("/data/ram", h.CreateRam).Methods("POST")
	r.HandleFunc("/data/ram/{id}", h.GetRam).Methods("GET")
	r.HandleFunc("/data/ram/{id}", h.UpdateRam).Methods("PATCH")
	r.HandleFunc("/data/ram/{id}", h.DeleteRam).Methods("DELETE")

	r.HandleFunc("/data/disk", h.CreateDisk).Methods("POST")
	r.HandleFunc("/data/disk", h.GetDisk).Methods("GET")
	r.HandleFunc("/data/disk", h.UpdateDisk).Methods("PATCH")
	r.HandleFunc("/data/disk", h.DeleteDisk).Methods("DELETE")

	r.HandleFunc("/data/device", h.CreateDevice).Methods("POST")
	r.HandleFunc("/data/device", h.GetDevice).Methods("GET")
	r.HandleFunc("/data/device", h.UpdateDevice).Methods("PATCH")
	r.HandleFunc("/data/device", h.DeleteDevice).Methods("DELETE")

	r.HandleFunc("/user/login", h.GetUser).Methods("POST")
	r.HandleFunc("/user/registration", h.CreateUser).Methods("POST")
	r.HandleFunc("/user/{id}", h.UpdateUser).Methods("PATCH")
	r.HandleFunc("/user/{id}", h.DeleteUser).Methods("DELETE")

	return r
}