format

package
v1.3.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 18, 2026 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FormatJSON

func FormatJSON(data []byte, indent string) (string, error)

FormatJSON formats JSON with proper indentation

func FormatXML

func FormatXML(data []byte, indent string) (string, error)

FormatXML formats XML with proper indentation

func MinifyJSON

func MinifyJSON(data []byte) (string, error)

MinifyJSON removes all unnecessary whitespace from JSON

func PrettyPrint

func PrettyPrint(contentType string, body []byte, maxLength int) string

PrettyPrint formats the response body for display in the TUI

func ValidateJSON

func ValidateJSON(data []byte) error

ValidateJSON checks if the data is valid JSON

Types

type ContentType

type ContentType string

ContentType represents the detected content type

const (
	ContentTypeJSON       ContentType = "json"
	ContentTypeXML        ContentType = "xml"
	ContentTypeHTML       ContentType = "html"
	ContentTypeText       ContentType = "text"
	ContentTypeJavaScript ContentType = "javascript"
	ContentTypeUnknown    ContentType = "unknown"
)

func DetectContentType

func DetectContentType(contentType string, body []byte) ContentType

DetectContentType attempts to detect the content type from headers and content

func Format

func Format(contentType string, body []byte) (string, ContentType, error)

Format automatically detects content type and formats accordingly

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL