forked from bouncepaw/mycorrhiza
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhandlers.go
68 lines (56 loc) · 1.71 KB
/
handlers.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
63
64
65
66
67
68
package main
import (
"github.com/gorilla/mux"
"log"
"net/http"
)
// Boilerplate code present in many handlers. Good to have it.
func HandlerBase(w http.ResponseWriter, r *http.Request) (Revision, bool) {
vars := mux.Vars(r)
revno := RevInMap(vars)
return GetRevision(hyphae, vars["hypha"], revno, w)
}
func HandlerGetBinary(w http.ResponseWriter, r *http.Request) {
if rev, ok := HandlerBase(w, r); ok {
rev.ActionGetBinary(w)
}
}
func HandlerRaw(w http.ResponseWriter, r *http.Request) {
if rev, ok := HandlerBase(w, r); ok {
rev.ActionRaw(w)
}
}
func HandlerZen(w http.ResponseWriter, r *http.Request) {
if rev, ok := HandlerBase(w, r); ok {
rev.ActionZen(w)
}
}
func HandlerView(w http.ResponseWriter, r *http.Request) {
if rev, ok := HandlerBase(w, r); ok {
rev.ActionView(w, HyphaPage)
}
}
func HandlerHistory(w http.ResponseWriter, r *http.Request) {
w.WriteHeader(http.StatusNotImplemented)
log.Println("Attempt to access an unimplemented thing")
}
func HandlerEdit(w http.ResponseWriter, r *http.Request) {
vars := mux.Vars(r)
ActionEdit(vars["hypha"], w)
}
func HandlerRewind(w http.ResponseWriter, r *http.Request) {
w.WriteHeader(http.StatusNotImplemented)
log.Println("Attempt to access an unimplemented thing")
}
func HandlerDelete(w http.ResponseWriter, r *http.Request) {
w.WriteHeader(http.StatusNotImplemented)
log.Println("Attempt to access an unimplemented thing")
}
func HandlerRename(w http.ResponseWriter, r *http.Request) {
w.WriteHeader(http.StatusNotImplemented)
log.Println("Attempt to access an unimplemented thing")
}
func HandlerUpdate(w http.ResponseWriter, r *http.Request) {
w.WriteHeader(http.StatusNotImplemented)
log.Println("Attempt to access an unimplemented thing")
}