|
|
@ -243,7 +243,6 @@ func prettyfyJSON(r io.Reader) ([]byte, error) {
|
|
243
|
243
|
if err != nil {
|
|
244
|
244
|
return nil, err
|
|
245
|
245
|
}
|
|
246
|
|
|
|
247
|
246
|
return json.MarshalIndent(val, "", " ")
|
|
248
|
247
|
}
|
|
249
|
248
|
|
|
|
@ -256,16 +255,6 @@ func renderYAML(w http.ResponseWriter, responses []Response) error {
|
|
256
|
255
|
return nil
|
|
257
|
256
|
}
|
|
258
|
257
|
|
|
259
|
|
func renderHTML(w http.ResponseWriter, responses []Response) error {
|
|
260
|
|
w.Header().Set("Content-Type", "text/html")
|
|
261
|
|
fmt.Fprintf(w, "<!doctype html><html><head><style>pre{max-width:100vw;padding:0.5em;background-color:#eee;white-space:pre-wrap;}</style></head><body><ul>\n")
|
|
262
|
|
for _, resp := range responses {
|
|
263
|
|
fmt.Fprintf(w, "<li><pre>%s</pre></li>\n", resp.String())
|
|
264
|
|
}
|
|
265
|
|
fmt.Fprintf(w, "\n</ul></body></html>")
|
|
266
|
|
return nil
|
|
267
|
|
}
|
|
268
|
|
|
|
269
|
258
|
// LogEntry is a request/respond pair for logging.
|
|
270
|
259
|
type LogEntry struct {
|
|
271
|
260
|
Request Request
|
|
|
@ -340,19 +329,6 @@ type Header struct {
|
|
340
|
329
|
Value string `yaml:"value"`
|
|
341
|
330
|
}
|
|
342
|
331
|
|
|
343
|
|
func readResponse(form url.Values) Response {
|
|
344
|
|
r := Response{}
|
|
345
|
|
r.Method = form.Get("method")
|
|
346
|
|
r.Path = form.Get("path")
|
|
347
|
|
r.Status = 200
|
|
348
|
|
headers := make([]Header, 0)
|
|
349
|
|
for i, name := range form["header"] {
|
|
350
|
|
headers = append(headers, Header{Name: name, Value: form["value"][i]})
|
|
351
|
|
}
|
|
352
|
|
r.Body = form.Get("body")
|
|
353
|
|
return r
|
|
354
|
|
}
|
|
355
|
|
|
|
356
|
332
|
// Load loads responses from the YAML file at path.
|
|
357
|
333
|
func (rs *Responses) Load(path string) {
|
|
358
|
334
|
responses, err := rs.loadFile(path)
|