Exemplo n.º 1
0
// dumps JSON data, used by log view. Methods allowed: GET
func getLogsHandler(w http.ResponseWriter, r *http.Request) {
	log.Println("--- getLogsHandler")
	messages, _ := gosms.GetMessages("")
	summary, _ := gosms.GetStatusSummary()
	dayCount, _ := gosms.GetLast7DaysMessageCount()
	logs := SMSDataResponse{
		Status:   200,
		Message:  "ok",
		Summary:  summary,
		DayCount: dayCount,
		Messages: messages,
	}
	var toWrite []byte
	toWrite, err := json.Marshal(logs)
	if err != nil {
		log.Println(err)
		//lets just depend on the server to raise 500
	}
	w.Header().Set("Content-type", "application/json")
	w.Write(toWrite)
}
Exemplo n.º 2
0
Arquivo: server.go Projeto: yoik/gosms
// dumps JSON data, used by log view. Methods allowed: GET
func getMessageHandler(w http.ResponseWriter, r *http.Request) {
	log.Println("--- getMessageHandler")

	r.ParseForm()
	uuid := r.FormValue("uuid")
	query := fmt.Sprintf("WHERE uuid='%v'", uuid)

	attempt, _ := gosms.GetMessages(query)
	logs := SMSMessageResponse{
		Status:  200,
		Message: "ok",
		Attempt: attempt[0],
	}
	var toWrite []byte
	toWrite, err := json.Marshal(logs)
	if err != nil {
		log.Println(err)
		//lets just depend on the server to raise 500
	}
	w.Header().Set("Content-type", "application/json")
	w.Write(toWrite)
}