Added endpoint to add a contact

This commit is contained in:
phoenix
2025-10-22 23:16:05 -04:00
parent a23c1a5f29
commit a9ebaf4ed4
3 changed files with 94 additions and 0 deletions
+11
View File
@@ -4,6 +4,17 @@ import "encoding/json"
import "log"
import "net/http"
func ExtractFromRequest(r *http.Request, reqItem interface{}) error {
err := json.NewDecoder(r.Body).Decode(&reqItem)
if err != nil {
return err
} else {
return nil
}
}
// Helper function to send JSON responses
func RespondWithJSON(w http.ResponseWriter, statusCode int, data interface{}) {
w.Header().Set("Content-Type", "application/json")