@@ -133,6 +133,7 @@ func Run() error {
133
133
http .HandleFunc ("/.export" , serveExport )
134
134
http .HandleFunc ("/.help" , serveHelp )
135
135
http .HandleFunc ("/.opensearch" , serveOpenSearch )
136
+ http .HandleFunc ("/.all" , serveAll )
136
137
http .Handle ("/.static/" , http .StripPrefix ("/." , http .FileServer (http .FS (embeddedFS ))))
137
138
138
139
if * dev != "" {
@@ -193,6 +194,9 @@ var (
193
194
// helpTmpl is the template used by the http://go/.help page
194
195
helpTmpl * template.Template
195
196
197
+ // allTmpl is the template used by the http://go/.all page
198
+ allTmpl * template.Template
199
+
196
200
// opensearchTmpl is the template used by the http://go/.opensearch page
197
201
opensearchTmpl * template.Template
198
202
)
@@ -213,6 +217,7 @@ func init() {
213
217
detailTmpl = template .Must (template .ParseFS (embeddedFS , "tmpl/base.html" , "tmpl/detail.html" ))
214
218
successTmpl = template .Must (template .ParseFS (embeddedFS , "tmpl/base.html" , "tmpl/success.html" ))
215
219
helpTmpl = template .Must (template .ParseFS (embeddedFS , "tmpl/base.html" , "tmpl/help.html" ))
220
+ allTmpl = template .Must (template .ParseFS (embeddedFS , "tmpl/base.html" , "tmpl/all.html" ))
216
221
opensearchTmpl = template .Must (template .ParseFS (embeddedFS , "tmpl/opensearch.xml" ))
217
222
}
218
223
@@ -282,6 +287,24 @@ func serveHome(w http.ResponseWriter, short string) {
282
287
})
283
288
}
284
289
290
+ func serveAll (w http.ResponseWriter , _ * http.Request ) {
291
+ if err := flushStats (); err != nil {
292
+ http .Error (w , err .Error (), http .StatusInternalServerError )
293
+ return
294
+ }
295
+
296
+ links , err := db .LoadAll ()
297
+ if err != nil {
298
+ http .Error (w , err .Error (), http .StatusInternalServerError )
299
+ return
300
+ }
301
+ sort .Slice (links , func (i , j int ) bool {
302
+ return links [i ].Short < links [j ].Short
303
+ })
304
+
305
+ allTmpl .Execute (w , links )
306
+ }
307
+
285
308
func serveHelp (w http.ResponseWriter , _ * http.Request ) {
286
309
helpTmpl .Execute (w , nil )
287
310
}
0 commit comments