16 lines
322 B
Go
16 lines
322 B
Go
package api
|
|
|
|
import (
|
|
"encoding/json"
|
|
"net/http"
|
|
)
|
|
|
|
func JSON(w http.ResponseWriter, status int, v any) {
|
|
w.Header().Set("Content-Type", "application/json")
|
|
w.WriteHeader(status)
|
|
json.NewEncoder(w).Encode(v)
|
|
}
|
|
|
|
func Error(w http.ResponseWriter, status int, msg string) {
|
|
JSON(w, status, ErrorResponse{Error: msg})
|
|
}
|