Added endpoint to add a contact
This commit is contained in:
@@ -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")
|
||||
|
||||
Reference in New Issue
Block a user