func()

in api.go [312:330]


func (h apiHandlers) postOrderCommon(c *gin.Context, customerID int, lines []ProductOrderLine) {
	customer, err := getCustomer(c.Request.Context(), h.db, customerID)
	if err != nil {
		c.AbortWithStatus(http.StatusNotFound)
		return
	}
	orderID, err := createOrder(c.Request.Context(), h.db, customer, lines)
	if err != nil {
		err := errors.Wrap(err, "failed to create order")
		c.AbortWithError(http.StatusInternalServerError, err)
		return
	}

	if tx := apm.TransactionFromContext(c.Request.Context()); tx != nil {
		tx.Context.SetLabel("customer_name", customer.FullName)
		tx.Context.SetLabel("customer_email", customer.Email)
	}
	c.JSON(http.StatusOK, gin.H{"id": orderID})
}