| // Copyright 2014 The Go Authors. All rights reserved. |
| // Use of this source code is governed by a BSD-style |
| // license that can be found in the LICENSE file. |
| func ExampleNewReader() { |
| Header: map[string][]string{ |
| "Content-Type": {"multipart/mixed; boundary=foo"}, |
| "--foo\r\nFoo: one\r\n\r\nA section\r\n" + |
| "--foo\r\nFoo: two\r\n\r\nAnd another\r\n" + |
| mediaType, params, err := mime.ParseMediaType(msg.Header.Get("Content-Type")) |
| if strings.HasPrefix(mediaType, "multipart/") { |
| mr := multipart.NewReader(msg.Body, params["boundary"]) |
| slurp, err := ioutil.ReadAll(p) |
| fmt.Printf("Part %q: %q\n", p.Header.Get("Foo"), slurp) |
| // Part "one": "A section" |
| // Part "two": "And another" |