acceptquery

package
v0.0.26 Latest Latest
Warning

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

Go to latest
Published: Sep 24, 2026 License: MIT Imports: 5 Imported by: 0

README

Accept-Query middleware

acceptquery advertises HTTP QUERY formats using the RFC 10008 Structured Fields representation and can reject unsupported QUERY content types.

formats := acceptquery.New(acceptquery.Config{
    MediaTypes: []string{"application/jsonpath", "application/sql; charset=UTF-8"},
    Enforce: true,
    RequireContentType: true,
})

app.Query("/search", formats, search)
app.Get("/search", formats, describeSearch)

Attach it to every representation of a resource that should advertise QUERY.

Documentation

Overview

Package acceptquery advertises and enforces HTTP QUERY request formats as defined by RFC 10008.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Build

func Build(mediaTypes []string) (field string, accepted []string, err error)

Build converts media types into the Structured Fields List syntax required by Accept-Query and also returns normalized base media types for enforcement.

func New

func New(cfg Config) fh.HandlerFunc

New returns route middleware that emits Accept-Query. When Enforce is true, QUERY requests using an unadvertised Content-Type are rejected with 415.

Types

type Config

type Config struct {
	MediaTypes         []string
	Enforce            bool
	RequireContentType bool
	Next               func(fh.Ctx) bool
}

Jump to

Keyboard shortcuts

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