Improve variable names
This commit is contained in:
parent
8796dfe73b
commit
45f160e1f1
12
main.go
12
main.go
|
@ -139,15 +139,15 @@ func save(raw string, lang string, title string, expiry string) []string {
|
||||||
|
|
||||||
}
|
}
|
||||||
delKey := uniuri.NewLen(40)
|
delKey := uniuri.NewLen(40)
|
||||||
paste := html.EscapeString(raw)
|
dataEscaped := html.EscapeString(raw)
|
||||||
|
|
||||||
stmt, err := db.Prepare("INSERT INTO pastebin(id, title, hash, data, delkey, expiry) values(?,?,?,?,?,?)")
|
stmt, err := db.Prepare("INSERT INTO pastebin(id, title, hash, data, delkey, expiry) values(?,?,?,?,?,?)")
|
||||||
check(err)
|
check(err)
|
||||||
if title == "" {
|
if title == "" {
|
||||||
_, err = stmt.Exec(id, id, sha, paste, delKey, expiryTime)
|
_, err = stmt.Exec(id, id, sha, dataEscaped, delKey, expiryTime)
|
||||||
check(err)
|
check(err)
|
||||||
} else {
|
} else {
|
||||||
_, err = stmt.Exec(id, html.EscapeString(title), sha, paste, delKey, expiryTime)
|
_, err = stmt.Exec(id, html.EscapeString(title), sha, dataEscaped, delKey, expiryTime)
|
||||||
check(err)
|
check(err)
|
||||||
}
|
}
|
||||||
db.Close()
|
db.Close()
|
||||||
|
@ -156,7 +156,7 @@ func save(raw string, lang string, title string, expiry string) []string {
|
||||||
|
|
||||||
func delHandler(w http.ResponseWriter, r *http.Request) {
|
func delHandler(w http.ResponseWriter, r *http.Request) {
|
||||||
vars := mux.Vars(r)
|
vars := mux.Vars(r)
|
||||||
paste := vars["pasteId"]
|
id := vars["pasteId"]
|
||||||
delkey := vars["delKey"]
|
delkey := vars["delKey"]
|
||||||
|
|
||||||
db, err := sql.Open("mysql", DATABASE)
|
db, err := sql.Open("mysql", DATABASE)
|
||||||
|
@ -165,14 +165,14 @@ func delHandler(w http.ResponseWriter, r *http.Request) {
|
||||||
stmt, err := db.Prepare("delete from pastebin where delkey=? and id=?")
|
stmt, err := db.Prepare("delete from pastebin where delkey=? and id=?")
|
||||||
check(err)
|
check(err)
|
||||||
|
|
||||||
res, err := stmt.Exec(html.EscapeString(delkey), html.EscapeString(paste))
|
res, err := stmt.Exec(html.EscapeString(delkey), html.EscapeString(id))
|
||||||
check(err)
|
check(err)
|
||||||
|
|
||||||
_, err = res.RowsAffected()
|
_, err = res.RowsAffected()
|
||||||
if err == sql.ErrNoRows {
|
if err == sql.ErrNoRows {
|
||||||
io.WriteString(w, "Error invalid paste")
|
io.WriteString(w, "Error invalid paste")
|
||||||
} else {
|
} else {
|
||||||
io.WriteString(w, paste+" deleted")
|
io.WriteString(w, id+" deleted")
|
||||||
}
|
}
|
||||||
db.Close()
|
db.Close()
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue