Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var Handler = http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { w.Header().Set("Strict-Transport-Security", "max-age=31536000") w.Header().Set("Content-Security-Policy", "default-src 'none'; font-src 'self'; img-src 'self'; script-src 'self'; style-src 'self'; base-uri 'none'; form-action 'self'; frame-ancestors 'none'") if m := path.FindStringSubmatch(r.URL.Path); m != nil { id, err := decodeID(m[1]) if err != nil { http.Error(w, err.Error(), http.StatusInternalServerError) return } servePaste(w, id, m[2]) } else if m := pathOld.FindStringSubmatch(r.URL.Path); m != nil { id, err := decodeOldID(m[1]) if err != nil { http.Error(w, err.Error(), http.StatusInternalServerError) return } if id >= 1000 { http.Error(w, "Forbidden", http.StatusForbidden) return } servePaste(w, id, m[2]) } else if r.URL.Path == "/create" { err := r.ParseForm() if err != nil { http.Error(w, err.Error(), http.StatusBadRequest) return } paste := r.Form.Get("paste") if len(paste) == 0 { http.Error(w, "No (or Invalid) Paste", http.StatusBadRequest) return } title := r.Form.Get("title") author := r.Form.Get("author") notes := r.Form.Get("notes") id, err := postPaste(&paste, &title, &author, ¬es) if err != nil { http.Error(w, err.Error(), http.StatusInternalServerError) return } http.Redirect(w, r, "/"+encodeID(id), http.StatusSeeOther) } else { assets.ServeHTTP(w, r) } })
Functions ¶
This section is empty.
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.