Beispiel #1
0
func writeHTTP(w http.ResponseWriter, e *storage.Envelope) error {
	w.Header().Set("X-Pluq-Message-Id", e.ID.HashID())
	w.Header().Set("X-Pluq-Queue-Name", e.Queue)
	w.Header().Set("X-Pluq-Retry-Remaining", e.Retry.String())
	w.Header().Set("X-Pluq-Timeout", e.Timeout.String())
	if !e.IsComposite() {
		w.Header().Set("Content-Type", e.Messages[0].ContentType)
		w.Write(e.Messages[0].Body)
		return nil
	}
	mw := multipart.NewWriter(w)
	defer mw.Close()
	for _, msg := range e.Messages {
		mh := make(textproto.MIMEHeader)
		mh.Set("Content-Type", msg.ContentType)
		pw, err := mw.CreatePart(mh)
		if err != nil {
			return err
		}
		pw.Write(msg.Body)
	}
	return nil
}
Beispiel #2
0
func setEID(e *storage.Envelope, id uid.ID) {
	if e != nil {
		e.ID = id
	}
}