diff options
Diffstat (limited to 'main.go')
-rw-r--r-- | main.go | 26 |
1 files changed, 26 insertions, 0 deletions
@@ -290,6 +290,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){ @@ -602,6 +617,17 @@ func main() { MakeActivityRequestOutbox(db, newActorActivity) http.Redirect(w, r, "/" + *Key, http.StatusSeeOther) }) + + http.HandleFunc("/" + *Key + "/postnews", func(w http.ResponseWriter, r *http.Request) { + var newsitem NewsItem + + newsitem.Title = r.FormValue("title") + newsitem.Content = r.FormValue("summary") + + WriteNewsToDB(db, newsitem) + + http.Redirect(w, r, "/", http.StatusSeeOther) + }) http.HandleFunc("/verify", func(w http.ResponseWriter, r *http.Request){ if(r.Method == "POST") { |