here we go

main
bel 2023-10-29 09:36:16 -06:00
parent 4de3b4a822
commit 09f3baee4d
2 changed files with 14 additions and 9 deletions

View File

@ -71,8 +71,6 @@ func Main() {
return
}
switch r.URL.Path {
case "/api/transactions":
reqF := f
if queryF := r.URL.Query().Get("f"); queryF != "" {
queryF = path.Join("http", queryF)
@ -81,6 +79,9 @@ func Main() {
panic(err)
}
}
switch r.URL.Path {
case "/api/transactions":
lastNLines, err := reqF.TempGetLastNLines(20)
if err != nil {
panic(err)
@ -104,7 +105,10 @@ func Main() {
if err := json.NewDecoder(r.Body).Decode(&lines); err != nil {
panic(err)
}
http.Error(w, "not done yet", http.StatusNotImplemented)
if err := reqF.TempSetLastNLines(20, lines); err != nil {
http.Error(w, err.Error(), http.StatusBadRequest)
}
w.WriteHeader(http.StatusResetContent)
return
}

View File

@ -79,6 +79,7 @@
}
function loadLastNLines(lastNLines) {
var result = `<form onsubmit="setLastNLines(this); return false;" action="#">`
result += ` <div>${f}</div>`
result += ` <textarea name="lastNLines">`
for (var k in lastNLines) {
result += lastNLines[k] + "\n"