httpcodec

package
v1.10.0-alpha.5 Latest Latest
Warning

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

Go to latest
Published: Oct 8, 2026 License: MIT Imports: 2 Imported by: 0

Documentation

Overview

Package httpcodec owns the built-in HTTP runtime's role-specific codec selection. Media labels, negotiation and decoder support are distinct inputs.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Kind

type Kind uint8

Kind identifies a built-in codec or a selector's explicit failure.

const (
	// Invalid means an explicit response Content-Type failed MIME parsing.
	Invalid Kind = iota
	// Unsupported means the request decoder does not support this media type.
	Unsupported
	// JSON selects the framework JSON codec.
	JSON
	// XML selects encoding/xml.
	XML
	// GOB selects encoding/gob.
	GOB
	// Text selects the framework text codec.
	Text
)

type Selection

type Selection struct {
	// Kind is the selected codec.
	Kind Kind
	// Media is normalized when parsing succeeds, otherwise the original input.
	Media string
}

Selection retains the media spelling used by runtime headers and errors.

func RequestContentType

func RequestContentType(media string) Selection

RequestContentType selects the server request decoder. Only exact built-in media types are accepted; a missing header defaults to JSON.

func ResponseAccept

func ResponseAccept(media string) Selection

ResponseAccept selects the server response encoder without a Content-Type override. Only exact built-in media are negotiated; all others default JSON.

func ResponseContentType

func ResponseContentType(media string) Selection

ResponseContentType selects an explicitly configured server response encoder. Invalid MIME returns Invalid; valid unknown types retain the JSON fallback.

func ResponseDecode

func ResponseDecode(media string) Selection

ResponseDecode selects the client response decoder. Parse failures retain the raw spelling for suffix dispatch. Missing or unmatched media default to JSON.

Jump to

Keyboard shortcuts

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