in src/checkoutservice/main.go [460:480]
func (cs *checkoutService) sendOrderConfirmation(ctx context.Context, email string, order *pb.OrderResult) error {
emailServicePayload, err := json.Marshal(map[string]interface{}{
"email": email,
"order": order,
})
if err != nil {
return fmt.Errorf("failed to marshal order to JSON: %+v", err)
}
resp, err := otelhttp.Post(ctx, cs.emailSvcAddr+"/send_order_confirmation", "application/json", bytes.NewBuffer(emailServicePayload))
if err != nil {
return fmt.Errorf("failed POST to email service: %+v", err)
}
defer resp.Body.Close()
if resp.StatusCode != http.StatusOK {
return fmt.Errorf("failed POST to email service: expected 200, got %d", resp.StatusCode)
}
return err
}