1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39
|
package response
import (
"fmt"
"strconv"
)
type status struct {
name string
items []Item
}
func Status() *status {
return &status{}
}
func (r *status) WithMailbox(name string) *status {
r.name = name
return r
}
func (r *status) WithItems(item ...Item) *status {
r.items = append(r.items, item...)
return r
}
func (r *status) Send(s Session) error {
return s.WriteResponse(r.String())
}
func (r *status) String() string {
var items []string
for _, item := range r.items {
items = append(items, item.String())
}
return fmt.Sprintf(`* STATUS %v (%v)`, strconv.Quote(r.name), join(items))
}
|