Пример #1
0
func postTrip(message *mq.Message) {
	var trip models.Trip
	trip.Initialize()
	trip.LoadJSON(message.Request.(string))

	if trip.Validate() {
		resp, err := db.Table("Trips").Insert(trip).RunWrite(session)
		util.LogOnError(err, "[Trip Worker] Erro inserting new Trip")

		message.ResponseCode = http.StatusOK
		message.Response = resp
	} else {
		message.ResponseCode = http.StatusBadRequest
		message.Response = nil
	}
}