Help us shape the future of Go! Take the 2026 Go Developer Survey

content

package
v2.3.85 Latest Latest
Warning

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

Go to latest
Published: Jul 21, 2026 License: Apache-2.0 Imports: 0 Imported by: 0

Documentation

Overview

Package content provides constants for common HTTP Content-Type header values.

These constants can be used when setting or checking Content-Type headers in HTTP requests and responses, ensuring consistency and avoiding typos in content type strings.

Example usage:

req.Header.Set("Content-Type", content.JSON)
if contentType == content.TextPlain {
    // handle plain text
}

Index

Constants

View Source
const (
	// TextPlain represents the "text/plain" content type for plain text data.
	// This is commonly used for simple text responses or requests without any
	// specific formatting or structure.
	//
	// Defined in RFC 2046, Section 4.1.3: https://www.rfc-editor.org/rfc/rfc2046.html#section-4.1.3
	TextPlain = "text/plain"

	// JSON represents the "application/json" content type for JSON-encoded data.
	// This is the standard content type for JSON payloads in HTTP requests and responses.
	//
	// Defined in RFC 8259: https://www.rfc-editor.org/rfc/rfc8259.html
	JSON = "application/json"

	// Json is deprecated. Use [JSON] instead.
	//
	// Deprecated: Use JSON for consistency with Go naming conventions.
	Json = JSON

	// FormEncoded represents the "application/x-www-form-urlencoded" content type.
	// This is used for HTML form submissions where form data is encoded as key-value
	// pairs in the request body, with keys and values URL-encoded.
	//
	// Defined in HTML 4.01 Specification, Section 17.13.4:
	// https://www.w3.org/TR/html401/interact/forms.html#h-17.13.4
	// Also referenced in WHATWG HTML Living Standard:
	// https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#application/x-www-form-urlencoded-encoding-algorithm
	FormEncoded = "application/x-www-form-urlencoded"
)

Variables

This section is empty.

Functions

This section is empty.

Types

This section is empty.

Jump to

Keyboard shortcuts

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