content

package
v1.348.0 Latest Latest
Warning

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

Go to latest
Published: Dec 22, 2024 License: MIT Imports: 9 Imported by: 1

Documentation

Index

Constants

View Source
const (

	// TypeKey for HTTP headers.
	TypeKey = "Content-Type"
)

Variables

This section is empty.

Functions

func NewHandler added in v1.286.0

func NewHandler[Res any](cont *Content, prefix string, handler Handler[Res]) http.HandlerFunc

NewHandler for content.

func NewRequestHandler added in v1.347.0

func NewRequestHandler[Req any, Res any](cont *Content, prefix string, handler RequestHandler[Req, Res]) http.HandlerFunc

NewRequestHandler for content.

Types

type Content added in v1.287.0

type Content struct {
	// contains filtered or unexported fields
}

Content creates types from media types.

func NewContent added in v1.287.0

func NewContent(enc *encoding.Map) *Content

NewContent with an encoding.

func (*Content) NewFromMedia added in v1.287.0

func (c *Content) NewFromMedia(mediaType string) *Media

NewFromMedia for content.

func (*Content) NewFromRequest added in v1.287.0

func (c *Content) NewFromRequest(req *http.Request) *Media

NewFromRequest for content.

type Handler added in v1.286.0

type Handler[Res any] func(ctx context.Context) (*Res, error)

Handler is a handler with a generic response.

type Media added in v1.340.0

type Media struct {
	// The encoder for the media type.
	Encoder encoding.Encoder

	// The type, e.g. text.
	Type string

	// The sub type, e.g. plain.
	Subtype string
}

Media for content. https://en.wikipedia.org/wiki/Media_type

func (*Media) IsText added in v1.340.0

func (t *Media) IsText() bool

IsText for type.

type RequestHandler added in v1.347.0

type RequestHandler[Req any, Res any] func(ctx context.Context, req *Req) (*Res, error)

RequestHandler is a handler with a generic request and response.

Jump to

Keyboard shortcuts

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