17 lines
378 B
Go
Executable File
17 lines
378 B
Go
Executable File
package marshaling
|
|
|
|
import (
|
|
"encoding/json"
|
|
"go_project/pkg/behaivor"
|
|
"io"
|
|
"net/http"
|
|
)
|
|
|
|
// NOTE: Not used in this project
|
|
func MustUnmarshalBody(r *http.Request, x interface{}) {
|
|
body, err := io.ReadAll(r.Body)
|
|
behaivor.Anxiety("Error reading the request body", err)
|
|
err = json.Unmarshal([]byte(body), x)
|
|
behaivor.Anxiety("Error unmarshaling the request body", err)
|
|
}
|