Beispiel #1
0
func PartsFromHeader(h *lob.Header) (Parts, error) {
	if h.IsZero() {
		return nil, nil
	}

	y := make(Parts, len(h.Extra))
	for k, v := range h.Extra {
		if len(k) != 2 {
			return nil, ErrInvalidParts
		}

		s, ok := v.(string)
		if !ok || s == "" {
			return nil, ErrInvalidParts
		}

		csid, err := hex.DecodeString(k)
		if err != nil {
			return nil, ErrInvalidParts
		}

		if len(s) != 52 {
			return nil, ErrInvalidParts
		}

		y[csid[0]] = s
	}

	return y, nil
}
Beispiel #2
0
func (k Keys) ApplyToHeader(h *lob.Header) {
	for csid, v := range k {
		h.Set(hex.EncodeToString([]byte{csid}), v.String())
	}
}
Beispiel #3
0
func (p Parts) ApplyToHeader(h *lob.Header) {
	for k, v := range p {
		h.Set(hex.EncodeToString([]byte{k}), v)
	}
}