serializer

package
v0.0.0-...-663df1f Latest Latest
Warning

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

Go to latest
Published: Apr 23, 2018 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type FormatHandler

type FormatHandler interface {
	Supports(format string) bool
	Handle(c *gin.Context, o interface{}) (interface{}, error)
}

FormatHandler defines the behavior of a handler

type GeoJSONHandler

type GeoJSONHandler struct{}

GeoJSONHandler is an struct implementing FormatHandler interface

func (GeoJSONHandler) Handle

func (GeoJSONHandler) Handle(c *gin.Context, o interface{}) (interface{}, error)

Handle marshal the data (from FormatHandler interface)

func (GeoJSONHandler) Supports

func (GeoJSONHandler) Supports(format string) bool

Supports defines which media type is supported (from FormatHandler interface)

type JSONAPIHandler

type JSONAPIHandler struct{}

JSONAPIHandler is an struct implementing FormatHandler interface

func (JSONAPIHandler) Handle

func (JSONAPIHandler) Handle(c *gin.Context, o interface{}) (interface{}, error)

Handle marshal the data (from FormatHandler interface)

func (JSONAPIHandler) Supports

func (JSONAPIHandler) Supports(format string) bool

Supports defines which media type is supported (from FormatHandler interface)

type Serializer

type Serializer struct {
	// contains filtered or unexported fields
}

Serializer is a registry of FormatHandler structs

func NewSerializer

func NewSerializer(h ...FormatHandler) Serializer

NewSerializer is the factory of Serializer

func (Serializer) Serialize

func (s Serializer) Serialize(c *gin.Context, o interface{}) ([]byte, error)

Serialize will fetch all handlers and try to find one which supports the requested format

Jump to

Keyboard shortcuts

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