serializer

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Jan 1, 2024 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

Package serializer provides an interface to read from request body or write to response body. Can be used for reading/writing JSON, XML, MessagePack, etc.

Currently the supported ones are JSON and XML.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Serializer

type Serializer interface {
	// Write writes object with the given indent to response body.
	Write(w http.ResponseWriter, in any, indent string)

	// Read reads request body and store it in the given object.
	Read(req *http.Request, out any) error
}

Serializer is the interface for reading from request body or writing to response body.

It can be implemented to read/write custom JSON/XML serializers.

func NewJSONSerializer

func NewJSONSerializer() Serializer

NewJSONSerializer returns a new JSON serializer.

func NewXMLSerializer

func NewXMLSerializer() Serializer

NewXMLSerializer returns a new XML serializer.

Jump to

Keyboard shortcuts

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