oficina / memoria Public

Clone
git clone https://amadan.net/oficina/memoria

Plain git — no account needed to clone.

Download

Download this file

1package main
2
3import (
4 "bytes"
5 "io"
6 "mime/multipart"
7 "net/http"
8)
9
10func multipartBody(title, body string) (io.Reader, string) {
11 var buf bytes.Buffer
12 mw := multipart.NewWriter(&buf)
13 mw.WriteField("title", title)
14 mw.WriteField("body", body)
15 mw.Close()
16 return &buf, mw.FormDataContentType()
17}
18
19// recorder is a minimal ResponseWriter — httptest is a test-only package
20// and this is a command.
21type recorder struct {
22 code int
23 header http.Header
24}
25
26func (r *recorder) Header() http.Header { return r.header }
27func (r *recorder) Write(b []byte) (int, error) { return len(b), nil }
28func (r *recorder) WriteHeader(c int) { r.code = c }
29