processor

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Jan 5, 2021 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package processor contains flexible implementations for rendering JSON, XML, CSV etc. A Processor is defined as

type Processor func(w http.ResponseWriter, match Match, template string, dataModel interface{}) error

Index

Constants

This section is empty.

Variables

View Source
var DefaultJSONOffer = acceptable.Offer{
	ContentType: acceptable.ContentType{
		Type:    "application",
		Subtype: "json",
	},
	Processor: JSON(),
}

DefaultJSONOffer is an Offer for application/json content using the JSON() processor without indentation.

View Source
var DefaultTXTOffer = acceptable.Offer{
	ContentType: acceptable.ContentType{
		Type:    "text",
		Subtype: "plain",
	},
	Processor: TXT(),
}

DefaultTXTOffer is an Offer for text/plain content using the TXT() processor.

View Source
var DefaultXMLOffer = acceptable.Offer{
	ContentType: acceptable.ContentType{
		Type:    "application",
		Subtype: "xml",
	},
	Processor: XML(),
}

DefaultXMLOffer is an Offer for application/xml content using the XML() processor without indentation.

Functions

func JSON

func JSON(indent ...string) acceptable.Processor

JSON creates a new processor for JSON with a specified indentation. It handles all requests except Ajax requests.

func TXT

func TXT() acceptable.Processor

TXT creates an output processor that serialises strings in a form suitable for text/plain responses. Model values should be one of the following:

* string

* fmt.Stringer

* encoding.TextMarshaler

func XML

func XML(indent ...string) acceptable.Processor

XML creates a new processor for XML with optional indentation.

Types

This section is empty.

Jump to

Keyboard shortcuts

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