(v any)
| 313 | } |
| 314 | |
| 315 | func (e *textEncoder) Encode(v any) (err error) { |
| 316 | switch c := v.(type) { |
| 317 | case string: |
| 318 | _, err = e.w.Write([]byte(c)) |
| 319 | case *string: // v may be a string pointer when the Response Body is set to the field of a custom response type. |
| 320 | _, err = e.w.Write([]byte(*c)) |
| 321 | case []byte: |
| 322 | _, err = e.w.Write(c) |
| 323 | default: |
| 324 | err = fmt.Errorf("can't encode %T as %s", c, e.ct) |
| 325 | } |
| 326 | return |
| 327 | } |
| 328 | |
| 329 | func newTextDecoder(r io.Reader, ct string) Decoder { |
| 330 | return &textDecoder{r, ct} |