diff options
author | knotteye <knotteye@airmail.cc> | 2021-07-01 20:26:49 -0500 |
---|---|---|
committer | knotteye <knotteye@airmail.cc> | 2021-07-01 20:26:49 -0500 |
commit | 168225daa21fe494bcd74ab6c90d6498ecf9f1e3 (patch) | |
tree | 65274dc8181e7c1805fb601f3674f6d357b5dc80 /main.go | |
parent | 4e3848cadbb3fd89b94a7ef24838173939d198db (diff) |
Make news list links to full page news articles
Diffstat (limited to 'main.go')
-rw-r--r-- | main.go | 15 |
1 files changed, 15 insertions, 0 deletions
@@ -286,6 +286,21 @@ func main() { w.WriteHeader(http.StatusForbidden) w.Write([]byte("404 no path")) }) + + http.HandleFunc("/news/", func(w http.ResponseWriter, r *http.Request){ + timestamp := r.URL.Path[6:] + if timestamp[len(timestamp)-1:] == "/" { + timestamp = timestamp[:len(timestamp)-1] + } + + ts, err := strconv.Atoi(timestamp) + if err != nil { + w.WriteHeader(http.StatusForbidden) + w.Write([]byte("404 no path")) + } else { + NewsGet(w, r, db, ts) + } + }) http.HandleFunc("/post", func(w http.ResponseWriter, r *http.Request){ |