-
Notifications
You must be signed in to change notification settings - Fork 1
/
endpoints.go
290 lines (284 loc) · 7.58 KB
/
endpoints.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
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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
package apiary
import (
"encoding/json"
"fmt"
"net/http"
"strings"
)
// ExampleURL provides an example URL to a different way of querying the API
// for any given endpoint.
type ExampleURL struct {
URL string `json:"url"`
Purpose string `json:"purpose"`
}
// Endpoint describes an endpoint available in this API and provides a sample path.
type Endpoint struct {
Name string `json:"name"`
URL string `json:"path"`
Examples []ExampleURL `json:"examples,omitempty"`
}
// EndpointsHandler describes the endpoints that are available in this API, with
// sample URLs to show how the API works.
func (s *Server) EndpointsHandler() http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
proto := "http://"
if r.TLS != nil {
proto = "https://"
}
baseurl := proto + r.Host
// These endpoints should correspond to the routes
endpoints := []Endpoint{
{
"Historial U.S. county boundaries by date from the Atlas of Historical County Boundaries",
baseurl + "/ahcb/counties/1844-05-08/",
nil,
},
{
"Historial U.S. county boundaries by date and county ID from the Atlas of Historical County Boundaries",
baseurl + "/ahcb/counties/1844-05-08/id/mas_essex,mas_middlesex/",
nil,
},
{
"Historial U.S. county boundaries by date and state/territory ID from the Atlas of Historical County Boundaries",
baseurl + "/ahcb/counties/1834-05-08/state-terr-id/nc_state,sc_state/",
nil,
},
{
"Historial U.S. county boundaries by date and state code from the Atlas of Historical County Boundaries",
baseurl + "/ahcb/counties/1844-05-08/state-code/nh,vt/",
nil,
},
{
"Historial U.S. state boundaries by date from the Atlas of Historical County Boundaries",
baseurl + "/ahcb/states/1820-05-10/",
nil,
},
{
"APB: Featured verses",
baseurl + "/apb/index/featured",
nil,
},
{
"APB: Top verses",
baseurl + "/apb/index/top",
nil,
},
{
"APB: Verses in biblical order",
baseurl + "/apb/index/biblical",
nil,
},
{
"APB: Verses in chronological order of peak quotations",
baseurl + "/apb/index/peaks",
nil,
},
{
"APB: All verses in biblical order",
baseurl + "/apb/index/all",
nil,
},
{
"APB: Verse",
baseurl + "/apb/verse?ref=Luke+18:16",
nil,
},
{
"APB: Verse trend",
baseurl + "/apb/verse-trend?ref=Luke+18:16&corpus=chronam",
nil,
},
{
"APB: Verse quotations",
baseurl + "/apb/verse-quotations?ref=Luke+18:16",
nil,
},
{
"APB: Bible trend",
baseurl + "/apb/bible-trend",
nil,
},
{
"APB: Bible similarity",
baseurl + "/apb/bible-similarity",
nil,
},
{
"APB: Books of the Bible",
baseurl + "/apb/bible-books",
nil,
},
{
"BOM: Total records",
baseurl + "/bom/totalbills?type=Weekly",
[]ExampleURL{
{
baseurl + "/bom/totalbills?type=Causes",
"Total records for causes of death",
},
{
baseurl + "/bom/totalbills?type=Christenings",
"Total records for christenings",
},
{
baseurl + "/bom/totalbills?type=Weekly",
"Total records for weekly bills",
},
{
baseurl + "/bom/totalbills?type=General",
"Total records for general bills",
},
},
},
{
"BOM: Parishes",
baseurl + "/bom/parishes",
nil,
},
{
"BOM: Bills of Mortality",
baseurl + "/bom/bills?start-year=1636&end-year=1754",
[]ExampleURL{
{
baseurl + "/bom/bills?start-year=1636&end-year=1754&bill-type=Weekly&parish=1,3,17,28&limit=50&offset=0",
"Weekly bills for a specific parish or set of parishes by ID. Bill type can be: Weekly or General.",
},
{
baseurl + "/bom/bills?start-year=1636&end-year=1754&count-type=Buried&limit=50&offset=0",
"Bills data for a specific count type (Buried or Plague). Specific parishes can be provided.",
},
{
baseurl + "/bom/bills?start-year=1636&end-year=1754&bill-type=Weekly&count-type=Buried&limit=50&offset=0",
"Bill type (Weekly or General) and count type (Buried or Plague) can be specific. Specific parishes can be provided.",
},
},
},
{
"BOM: Causes of Death",
baseurl + "/bom/causes?start-year=1648&end-year=1754&limit=50&offset=0",
[]ExampleURL{
{
baseurl + "/bom/causes",
"Return all causes of death",
},
{
baseurl + "/bom/causes?start-year=1648&end-year=1754",
"Causes of death for a specific year range",
},
{
baseurl + "/bom/causes?start-year=1648&end-year=1754&id=Aged,Drowned",
"Causes of death for a specific year range and cause IDs",
},
},
},
{
"BOM: Christenings",
baseurl + "/bom/christenings?start-year=1669&end-year=1754&limit=50&offset=0",
[]ExampleURL{
{
baseurl + "/bom/christenings?start-year=1669&end-year=1754&id=1,3,17,28",
"Christenings for a specific year range and parish IDs",
},
},
},
{
"BOM: List of unique Causes of Death",
baseurl + "/bom/list-deaths",
nil,
},
{
"BOM: List of unique Christening Parishes",
baseurl + "/bom/list-christenings",
nil,
},
{
"Roman Catholic Dioceses in North America",
baseurl + "/catholic-dioceses/",
nil,
},
{
"Roman Catholic Dioceses in North America: number established per decade",
baseurl + "/catholic-dioceses/per-decade/",
nil,
},
{
"Countries from Natural Earth",
baseurl + "/ne/globe?location=Europe",
[]ExampleURL{
{
baseurl + "/ne/globe",
"All available polygons for all countries",
},
{
baseurl + "/ne/globe?location=Europe",
"All available polygons for Europe",
},
{
baseurl + "/ne/globe?location=Europe&location=Asia",
"All available polygons for Europe and Asia",
},
},
},
{
"Populated places: A list of counties in a state",
baseurl + "/pop-places/state/ma/county/",
nil,
},
{
"Populated places: A list of places in a county",
baseurl + "/pop-places/county/cas_ventura/place/",
nil,
},
{
"Populated places: Information about a populated place",
baseurl + "/pop-places/place/611119/",
nil,
},
{
"Presbyterian statistics, 1826-1926",
baseurl + "/presbyterians/",
nil,
},
{
"Religious Bodies Census denomination families",
baseurl + "/relcensus/denomination-families",
nil,
},
{
"Religious Bodies Census denominations",
baseurl + "/relcensus/denominations",
nil,
},
{
"Religious Bodies Census membership data for a denomination in a city in a year",
baseurl + "/relcensus/city-membership?year=1926&denomination=Protestant+Episcopal+Church",
[]ExampleURL{
{
baseurl + "/relcensus/city-membership?year=1926&denomination=Church+of+God+in+Christ",
"Membership data for a specific denomination in each city",
},
{
baseurl + "/relcensus/city-membership?year=1926&denominationFamily=Pentecostal",
"Membership data aggregated for a denomination family in each city",
},
{
baseurl + "/relcensus/city-membership?year=1926",
"Membership data aggregated for all denominations in each city",
},
},
},
{
"Cache test",
baseurl + "/cache",
[]ExampleURL{
{baseurl + "/cache", "Cached response"},
{baseurl + "/cache?nocache", "Uncached response"},
},
},
}
response, _ := json.MarshalIndent(endpoints, "", " ")
resp := strings.Replace(string(response), "\\u0026", "&", -1)
w.Header().Set("Content-Type", "application/json")
fmt.Fprint(w, resp)
}
}