contenttype

package
v1.3.0 Latest Latest
Warning

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

Go to latest
Published: Mar 6, 2026 License: AGPL-3.0, AGPL-3.0-or-later Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsBinary

func IsBinary(contentType string, data []byte) bool

IsBinary returns true if the content type indicates binary content. Falls back to UTF-8 validation when contentType is empty or unrecognized and data is provided.

func IsJSON

func IsJSON(contentType string) bool

IsJSON returns true if the content type indicates JSON (case-insensitive).

Types

type Category

type Category string

Category represents a broad content-type classification.

const (
	JSON   Category = "json"
	XML    Category = "xml"
	HTML   Category = "html"
	YAML   Category = "yaml"
	CSV    Category = "csv"
	Form   Category = "form"
	Text   Category = "text"
	Binary Category = "binary"
)

func Classify

func Classify(contentType string) Category

Classify returns the broad content category for a content-type header value. Uses mime.ParseMediaType to strip parameters (charset, boundary, etc.) before matching. Falls back to strings.ToLower for malformed values. Returns Binary for empty content-type strings.

Jump to

Keyboard shortcuts

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