-
Notifications
You must be signed in to change notification settings - Fork 22
/
Copy pathrouter.go
62 lines (51 loc) · 1.75 KB
/
router.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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
package main
import (
"net/http"
"github.com/gorilla/mux"
)
// Router returns a gorila/mux Router with all specified endpoints and
// handlers.
func Router(conn *Conn) *mux.Router {
r := mux.NewRouter()
// GET /
r.HandleFunc("/", conn.rootHandler).
Methods("GET")
// GET /_ping
// HEAD /_ping
r.HandleFunc("/_ping", conn.pingHandler).
Methods("GET", "HEAD")
// GET /_status
r.HandleFunc("/_status", conn.statusHandler).
Methods("GET")
// GET /_config
r.HandleFunc("/_config", conn.configHandler).
Methods("GET")
// GET /_config/$CONFIG_KEY
// POST /_config/$CONFIG_KEY + {element: value}
r.Handle("/_config/{key}", conn.configKeyHandler("")).
Methods("GET", "POST")
// GET /databases
// PUT /databases?name=DATABASE_NAME
r.HandleFunc("/databases", conn.databasesHandler).
Methods("GET", "PUT")
// GET /databases/$DATABASE_ID
// DELETE /databases/$DATABASE_ID
r.Handle("/databases/{id}", conn.databaseHandler("")).
Methods("GET", "DELETE")
// GET /databases/$DATABASE_ID/stacks
// GET /databases/$DATABASE_ID/stacks?kv
// PUT /databases/$DATABASE_ID/stacks?name=STACK_NAME
r.Handle("/databases/{database_id}/stacks", conn.stacksHandler("")).
Methods("GET", "PUT")
// GET /databases/$DATABASE_ID/stacks/$STACK_ID
// GET /databases/$DATABASE_ID/stacks/$STACK_ID?peek
// GET /databases/$DATABASE_ID/stacks/$STACK_ID?size
// POST /databases/$DATABASE_ID/stacks/$STACK_ID + {element: value}
// DELETE /databases/$DATABASE_ID/stacks/$STACK_ID
// DELETE /databases/$DATABASE_ID/stacks/$STACK_ID?flush
// DELETE /databases/$DATABASE_ID/stacks/$STACK_ID?full
r.Handle("/databases/{database_id}/stacks/{stack_id}", conn.stackHandler(nil)).
Methods("GET", "POST", "DELETE")
r.NotFoundHandler = http.HandlerFunc(conn.notFoundHandler)
return r
}