jsonmw

package
v2.0.1 Latest Latest
Warning

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

Go to latest
Published: Feb 2, 2026 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Overview

Package jsonmw provides jsonmw utilities.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func StrictDecoder

func StrictDecoder(r *http.Request) (*json.Decoder, error)

StrictDecoder creates a JSON decoder that disallows unknown fields.

Types

type Middleware

type Middleware struct {
	RequireJSON bool
}

Middleware enforces JSON content-type requirements.

func New

func New(opts Options) (*Middleware, error)

New constructs a JSON middleware with the given requirement.

func (*Middleware) Handler

func (m *Middleware) Handler(next http.Handler) http.Handler

Handler wraps the next handler with JSON content checks.

func (*Middleware) Middleware

func (m *Middleware) Middleware() func(http.Handler) http.Handler

Middleware implements ports.Middleware by returning the Handler adapter.

type Options

type Options struct {
	RequireJSON bool
}

Options configures the JSON middleware.

Jump to

Keyboard shortcuts

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