Use JSON for errors and page response

This commit is contained in:
Ian Gulliver
2024-11-26 13:26:26 -06:00
parent 89737edbd6
commit 0512fa41f6
7 changed files with 69 additions and 16 deletions

14
response.go Normal file
View File

@@ -0,0 +1,14 @@
package main
import (
"fmt"
"net/http"
)
type Response struct {
Message string `json:"message"`
}
func sendResponse(w http.ResponseWriter, msg string, args ...any) {
sendJSON(w, Response{Message: fmt.Sprintf(msg, args...)})
}