コード例 #1
0
ファイル: handlers_queue.go プロジェクト: teefax/tmail
// usersGetAll return all users
func queueGetMessages(w http.ResponseWriter, r *http.Request) {
	if !authorized(w, r) {
		return
	}
	messages, err := api.QueueGetMessages()
	if err != nil {
		httpWriteErrorJson(w, 500, "unable to get message in queue", err.Error())
		return
	}
	js, err := json.Marshal(messages)
	if err != nil {
		httpWriteErrorJson(w, 500, "JSON encondig failed", err.Error())
		return
	}
	httpWriteJson(w, js)
}
コード例 #2
0
ファイル: queue.go プロジェクト: teefax/tmail
	cgCli "github.com/codegangsta/cli"
	"github.com/toorop/tmail/api"
)

var Queue = cgCli.Command{
	Name:  "queue",
	Usage: "commands to interact with tmail queue",
	Subcommands: []cgCli.Command{
		// list queue
		{
			Name:        "list",
			Usage:       "List messages in queue",
			Description: "tmail queue list",
			Action: func(c *cgCli.Context) {
				var status string
				messages, err := api.QueueGetMessages()
				cliHandleErr(err)
				if len(messages) == 0 {
					println("There is no message in queue.")
				} else {
					fmt.Printf("%d messages in queue.\r\n", len(messages))
					for _, m := range messages {
						switch m.Status {
						case 0:
							status = "Delivery in progress"
						case 1:
							status = "Will be discarded"
						case 2:
							status = "Scheduled"
						case 3:
							status = "Will be bounced"