-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathapi.go
More file actions
93 lines (86 loc) · 2.38 KB
/
Copy pathapi.go
File metadata and controls
93 lines (86 loc) · 2.38 KB
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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
package xmux
// func css(w http.ResponseWriter, r *http.Request) {
// filename := Var(r)["name"]
// switch filename {
// case "style":
// w.Write([]byte(style))
// return
// case "left":
// w.Write([]byte(cssleft))
// return
// case "font":
// w.Write([]byte(font))
// return
// }
// }
// func js(w http.ResponseWriter, r *http.Request) {
// filename := Var(r)["name"]
// switch filename {
// case "jquery":
// w.Write([]byte(jqueryMin))
// return
// case "left":
// w.Write([]byte(left))
// return
// case "slimscroll":
// w.Write([]byte(slimscroll))
// return
// case "click":
// w.Write([]byte(click))
// return
// }
// }
// func showThisDoc(w http.ResponseWriter, r *http.Request) {
// id := Var(r)["id"]
// t := NewTemplate()
// intid, _ := strconv.Atoi(id)
// if api, ok := apiDocument[intid]; ok {
// api.Sidebar = sidebar
// err := t.Execute(w, api)
// if err != nil {
// w.Write([]byte(err.Error()))
// }
// return
// } else {
// apiDocument[0] = Doc{
// Title: "this is document home page",
// Sidebar: sidebar,
// }
// http.Redirect(w, r, "/-/api/0.html", 302)
// }
// }
// func homeDoc(w http.ResponseWriter, r *http.Request) {
// w.Header().Set("Content-Type", "text/html; charset=UTF-8")
// t := NewHomeTemplate()
// apiDocument[0] = Doc{
// Title: "this is document home page",
// Sidebar: sidebar,
// }
// err := t.Execute(w, apiDocument[0])
// if err != nil {
// w.Write([]byte(err.Error()))
// }
// w.WriteHeader(http.StatusOK)
// }
// func testdoc(w http.ResponseWriter, r *http.Request) {
// send, err := json.Marshal(apiDocument)
// if err != nil {
// fmt.Println(err)
// return
// }
// w.Write(send)
// }
// func (r *Router) ShowApi(pattern string) *RouteGroup {
// if !r.new {
// panic("must be use get router by NewRouter()")
// }
// api := NewRouteGroup()
// NewDocs(r)
// api.Get("/-/js/{name}.js", js).SetHeader("Content-Type", "application/javascript; charset=utf8")
// api.Get("/-/css/{name}.css", css).SetHeader("Content-Type", "text/css; charset=utf8")
// api.Get("/-/api/{int:id}.html", showThisDoc).SetHeader("Content-Type", "text/html; charset=UTF-8")
// api.Get("/-/api/0.html", homeDoc).SetHeader("Content-Type", "text/html; charset=UTF-8")
// api.Get("/-/api/help", testdoc).SetHeader("Content-Type", "text/html; charset=UTF-8")
// api.Get(pattern, homeDoc)
// return api
// }