ScuttleBot

scuttlebot / internal / api / respond.go
Blame History Raw 17 lines
1
package api
2
3
import (
4
"encoding/json"
5
"net/http"
6
)
7
8
func writeJSON(w http.ResponseWriter, status int, v any) {
9
w.Header().Set("Content-Type", "application/json")
10
w.WriteHeader(status)
11
_ = json.NewEncoder(w).Encode(v)
12
}
13
14
func writeError(w http.ResponseWriter, status int, msg string) {
15
writeJSON(w, status, map[string]string{"error": msg})
16
}
17

Keyboard Shortcuts

Open search /
Next entry (timeline) j
Previous entry (timeline) k
Open focused entry Enter
Show this help ?
Toggle theme Top nav button