httpvalidation

package
v0.0.0-...-991afdd Latest Latest
Warning

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

Go to latest
Published: Dec 2, 2025 License: AGPL-3.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrInvalidContentType is returned when Content-Type header is not application/json
	ErrInvalidContentType = errors.New("Content-Type must be application/json")
	// ErrMissingContentType is returned when Content-Type header is missing
	ErrMissingContentType = errors.New("Content-Type header is required")
)

Functions

func RequireJSONContentType

func RequireJSONContentType(r *http.Request) error

RequireJSONContentType validates that the request has application/json Content-Type CWE-436: Strict validation that requires Content-Type header Use this for new endpoints where you want to enforce the header

func ValidateJSONContentType

func ValidateJSONContentType(r *http.Request) error

ValidateJSONContentType validates that the request has application/json Content-Type CWE-436: Validates Content-Type before parsing to prevent interpretation conflicts Accepts both "application/json" and "application/json; charset=utf-8"

func ValidateJSONContentTypeStrict

func ValidateJSONContentTypeStrict(r *http.Request) error

ValidateJSONContentTypeStrict validates that the request has application/json Content-Type CWE-16: Configuration - Enforces strict Content-Type validation This version REQUIRES the Content-Type header and returns specific error for missing header

Types

This section is empty.

Jump to

Keyboard shortcuts

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