echo4

package
v0.38.0 Latest Latest
Warning

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

Go to latest
Published: Dec 13, 2023 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

package echo4 provides adapters for easily using acceptable functions with Echo v4.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BestRequestMatch

func BestRequestMatch(c echo.Context, available ...offer.Offer) *offer.Match

BestRequestMatch finds the content type and language that best matches the accepted media ranges and languages contained in request headers. The result contains the best match, based on the rules of RFC-7231. On exit, the result will contain the preferred language and charset, if these are known.

Whenever the result is nil, the response should be 406-Not Acceptable.

For all Ajax requests, the available offers are filtered so that only those capable of providing an Ajax response are considered by the content negotiation algorithm. The other offers are discarded.

The order of offers is important. It determines the order they are compared against the request headers, and it determines what defaults will be used when exact matching is not possible.

If no available offers are provided, the response will always be nil. Note too that Ajax requests will result in nil being returned if no offer is capable of handling them, even if other offers are provided.

func RenderBestMatch

func RenderBestMatch(c echo.Context, statusCode int, template string, available ...offer.Offer) error

RenderBestMatch uses BestRequestMatch to find the best matching offer for the request, and then renders the response. If statusCode is 0, the default (200-status OK) will be used.

Types

This section is empty.

Jump to

Keyboard shortcuts

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