body

package
v1.0.3 Latest Latest
Warning

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

Go to latest
Published: Jan 28, 2020 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CheckContentType

func CheckContentType(contentType string) bool

CheckContentType is used to validate if the content type exists or not.

func GetContenTypeString

func GetContenTypeString(contentType pb.Constant_ContentType) string

GetContenTypeString is used to convert enum value of content type to string.

func GetContentTypeValue

func GetContentTypeValue(header http.Header) (contentType pb.Constant_ContentType, rawContentType string, err error)

GetContentTypeValue is used to convert content type from http request to enum value.

func Marshal

func Marshal(msg proto.Message) (b []byte, err error)

Marshal is used to marshal protobuf message to http response body (JSON format only).

func Unmarshal

func Unmarshal(wrappedReq *pb.Request, msg proto.Message) (err error)

Unmarshal is used to unmarshal http body to protobuf message.

Types

type HTTPBody

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

HTTPBody implements io.ReadCloser to keep HTTP body data.

func NewHTTPBody

func NewHTTPBody(p []byte) *HTTPBody

NewHTTPBody is used to create HTTPBody.

func (*HTTPBody) Close

func (b *HTTPBody) Close() error

Close is used to implement io.Closer.

func (*HTTPBody) Raw

func (b *HTTPBody) Raw() []byte

Raw is used to get raw HTTP body directly without removing the data.

func (*HTTPBody) Read

func (b *HTTPBody) Read(p []byte) (n int, err error)

Read is used to implement io.Reader.

Jump to

Keyboard shortcuts

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