codec

package
v0.1.4 Latest Latest
Warning

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

Go to latest
Published: Jan 23, 2018 License: Apache-2.0 Imports: 5 Imported by: 9

Documentation

Index

Constants

View Source
const (
	// Default is the default content type
	Default = YAML

	// YAML is the yaml codec content type
	YAML = "application/yaml"

	// JSON is the json codec content type
	JSON = "application/json"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type ContentTypeHandler

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

ContentTypeHandler is a helper for working with Content-Type header and doing read/write for http requests/response

func NewContentTypeHandler

func NewContentTypeHandler(reg *runtime.Registry) *ContentTypeHandler

NewContentTypeHandler returns instance of ContentTypeHandler for provided runtime registry

func (*ContentTypeHandler) GetCodec

func (handler *ContentTypeHandler) GetCodec(header http.Header) runtime.Codec

GetCodec returns runtime codec for specified http headers based on the content type

func (*ContentTypeHandler) GetCodecByContentType

func (handler *ContentTypeHandler) GetCodecByContentType(contentType string) runtime.Codec

GetCodecByContentType returns runtime codec for provided content type that should be used

func (*ContentTypeHandler) GetContentType

func (handler *ContentTypeHandler) GetContentType(header http.Header) string

GetContentType returns content type for provided http headers

func (*ContentTypeHandler) Read

func (handler *ContentTypeHandler) Read(request *http.Request) []runtime.Object

Read runtime object(s) from the provided request using correct content type (taken from the request)

func (*ContentTypeHandler) WriteMany

func (handler *ContentTypeHandler) WriteMany(writer http.ResponseWriter, request *http.Request, body []runtime.Object)

WriteMany runtime objects into the provided response writer using correct content type (taken from provided request) with default http status (200 OK)

func (*ContentTypeHandler) WriteManyWithStatus

func (handler *ContentTypeHandler) WriteManyWithStatus(writer http.ResponseWriter, request *http.Request, body []runtime.Object, status int)

WriteManyWithStatus runtime objects into the provided response writer using correct content type (taken from provided request) with specified http status

func (*ContentTypeHandler) WriteOne

func (handler *ContentTypeHandler) WriteOne(writer http.ResponseWriter, request *http.Request, body runtime.Object)

WriteOne runtime object into the provided response writer using correct content type (taken from provided request) with default http status (200 OK)

func (*ContentTypeHandler) WriteOneWithStatus

func (handler *ContentTypeHandler) WriteOneWithStatus(writer http.ResponseWriter, request *http.Request, body runtime.Object, status int)

WriteOneWithStatus runtime object into the provided response writer using correct content type (taken from provided request) with specified http status

Jump to

Keyboard shortcuts

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