Print response header keys in color too

This commit is contained in:
Mislav Marohnić 2020-06-08 15:18:06 +02:00
parent 62549465a0
commit fd1e87beeb

View file

@ -100,8 +100,13 @@ func apiRun(opts *ApiOptions) error {
}
if opts.ShowResponseHeaders {
var headerColor, headerColorReset string
if opts.IO.ColorEnabled() {
headerColor = "\x1b[1;34m" // bright blue
headerColorReset = "\x1b[m"
}
for name, vals := range resp.Header {
fmt.Fprintf(opts.IO.Out, "%s: %s\r\n", name, strings.Join(vals, ", "))
fmt.Fprintf(opts.IO.Out, "%s%s%s: %s\r\n", headerColor, name, headerColorReset, strings.Join(vals, ", "))
}
fmt.Fprint(opts.IO.Out, "\r\n")
}