Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

### Features include:

- **Response formatting**: automatically formats and colors output (json, html, csv, msgpack, protobuf, xml, etc.)
- **Response formatting**: automatically formats and colors output (json, html, xml, css, csv, msgpack, protobuf, etc.)
- **Image rendering**: render images directly in your terminal
- **Compression**: automatic gzip and zstd response body decompression
- **Authentication**: support for Basic Auth, Bearer Token, and AWS Signature V4
Expand Down
1 change: 1 addition & 0 deletions docs/USAGE.md
Original file line number Diff line number Diff line change
Expand Up @@ -336,6 +336,7 @@ Supported formats for automatic formatting and syntax highlighting:
- JSON (`application/json`)
- HTML (`text/html`)
- XML (`application/xml`, `text/xml`)
- CSS (`text/css`)
- CSV (`text/csv`)
- MessagePack (`application/msgpack`)
- NDJSON/JSONLines (`application/x-ndjson`)
Expand Down
7 changes: 7 additions & 0 deletions internal/fetch/fetch.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ type ContentType int

const (
TypeUnknown ContentType = iota
TypeCSS
TypeCSV
TypeHTML
TypeImage
Expand Down Expand Up @@ -286,6 +287,10 @@ func formatResponse(ctx context.Context, r *Request, resp *http.Response) (io.Re
}

switch contentType {
case TypeCSS:
if format.FormatCSS(buf, p) == nil {
buf = p.Bytes()
}
case TypeCSV:
if format.FormatCSV(buf, p) == nil {
buf = p.Bytes()
Expand Down Expand Up @@ -357,6 +362,8 @@ func getContentType(headers http.Header) ContentType {
}
case "text":
switch subtype {
case "css":
return TypeCSS
case "csv":
return TypeCSV
case "html":
Expand Down
Loading