From 5310d08bda170e2d394d27410655283e1797b7ff Mon Sep 17 00:00:00 2001 From: Ben Morrison Date: Mon, 13 May 2019 00:42:48 -0400 Subject: watching for ^C. added comments. --- main.go | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) (limited to 'main.go') diff --git a/main.go b/main.go index 267c4ea..25d95af 100644 --- a/main.go +++ b/main.go @@ -17,7 +17,7 @@ func main() { index := mux.NewRouter().StrictSlash(true) api := index.PathPrefix("/api").Subrouter() - // gorilla/mux makes path validation painless + // <3 gorilla/mux index.Path("/"). Methods("GET"). HandlerFunc(indexHandler) @@ -27,16 +27,26 @@ func main() { api.Path("/"). Methods("GET"). HandlerFunc(apiBaseHandler) + // twtxt will add support for other formats later. + // Maybe json? Making this future-proof. api.Path("/{format:(?:plain)}"). Methods("GET"). HandlerFunc(apiFormatHandler) + // Specifying the endpoint with and without query information. + // Will return 404 on empty queries otherwise. api.Path("/{format:(?:plain)}/{endpoint:(?:mentions|users|tweets)}"). Methods("GET"). + HandlerFunc(apiEndpointHandler) + // Using stdlib net/url to validate the input URLs rather than regex. + // Validating a URL with regex is unwieldly + api.Path("/{format:(?:plain)}/{endpoint:(?:mentions|users|tweets)}"). Queries("url", "{url}", "q", "{query}"). + Methods("GET"). HandlerFunc(apiEndpointHandler) + // This is for submitting new users api.Path("/{format:(?:plain)}/{endpoint:users}"). + Queries("url", "{url}", "nickname", "{nickname:[a-zA-Z0-9]+}"). Methods("POST"). - Queries("url", "{url}", "nickname", "{nickname}"). HandlerFunc(apiEndpointPOSTHandler) api.Path("/{format:(?:plain)}/tags"). Methods("GET"). -- cgit 1.4.1-2-gfad0 m'>
path: root/themes/mono
blob: e40a3278e09855142452152ea471af4c0cadfda5 (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
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