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

contenttype

package
v0.7.3 Latest Latest
Warning

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

Go to latest
Published: Oct 5, 2026 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package contenttype rejects request bodies of media types or content codings the application does not accept.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func New

func New(configs ...Config) zinc.Middleware

New answers 415 Unsupported Media Type for a request whose Content-Type or Content-Encoding is not listed in config.

Types

type Config

type Config struct {
	// Types are the accepted media types, such as "application/json".
	// Parameters are ignored, so "application/json; charset=utf-8" matches.
	Types []string
	// Encodings are the accepted content codings, such as "gzip". A request
	// without Content-Encoding is "identity", so list it to allow plain bodies.
	Encodings []string
}

Config lists what requests may send. An empty list allows anything.

Jump to

Keyboard shortcuts

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