Пример #1
0
//Get manages get method requests
func (t TripHandler) Get(request *http.Request, vars map[string]string) (int, interface{}) {

	var message mq.Message
	message.CorrelationID = uuid.NewV4().String()
	if vars["id"] == "" {
		message.RequestAction = "GET_ALL"
	} else {
		message.RequestAction = "GET"
		message.Request = vars["id"]
	}

	Tasks.PublishMessage(message, "Trip", message.CorrelationID, "callback")

	return processMessage(&message)
}
Пример #2
0
//Post manages post method requests
func (t TripHandler) Post(request *http.Request) (int, interface{}) {
	body, err := ioutil.ReadAll(request.Body)
	util.LogOnError(err, "Post error reading request body")

	var message mq.Message
	message.CorrelationID = uuid.NewV4().String()
	message.RequestAction = "POST"
	message.Request = string(body)

	Tasks.PublishMessage(message, "Trip", message.CorrelationID, "callback")

	return processMessage(&message)
}