body

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Mar 20, 2021 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const KeyError = "error"
View Source
const KeyForm = "form"
View Source
const KeyHTML = "html"
View Source
const KeyImage = "image"
View Source
const KeyJSON = "json"
View Source
const KeyLarge = "large"
View Source
const KeyRaw = "raw"
View Source
const KeyXML = "xml"

Variables

This section is empty.

Functions

This section is empty.

Types

type Body

type Body struct {
	Type   string `json:"type"`
	Length int64  `json:"length"`
	Config Config `json:"config"`
}

func NewBody

func NewBody(t string, c Config) *Body

func NewError

func NewError(message string) *Body

func NewForm

func NewForm(data ...*FormEntry) *Body

func NewHTML

func NewHTML(content string) *Body

func NewImage

func NewImage(t string, bytes []byte) *Body

func NewJSON

func NewJSON(msg interface{}) *Body

func NewLarge

func NewLarge(filename string, contentType string, length int64) *Body

func NewRaw

func NewRaw(bytes []byte) *Body

func NewXML

func NewXML(content string) *Body

func Parse

func Parse(path string, contentEncoding string, contentType string, charset string, contentLength int64, rd io.ReadCloser) (*Body, error)

func (*Body) Clone

func (b *Body) Clone() *Body

func (*Body) ContentLength

func (b *Body) ContentLength() int64

func (*Body) Merge

func (b *Body) Merge(data npncore.Data, logger *logrus.Logger) *Body

func (*Body) String

func (b *Body) String() string

func (*Body) ToHTTP

func (b *Body) ToHTTP() io.ReadCloser

func (*Body) UnmarshalJSON

func (b *Body) UnmarshalJSON(data []byte) error

type Config

type Config interface {
	ContentLength() int64
	Bytes() []byte
	MimeType() string
	String() string
	Merge(data npncore.Data, logger *logrus.Logger) Config
	Clone() *Body
}

type Error

type Error struct {
	Message string `json:"message"`
}

func (*Error) Bytes

func (e *Error) Bytes() []byte

func (*Error) Clone

func (e *Error) Clone() *Body

func (*Error) ContentLength

func (e *Error) ContentLength() int64

func (*Error) Merge

func (e *Error) Merge(data npncore.Data, logger *logrus.Logger) Config

func (*Error) MimeType

func (e *Error) MimeType() string

func (*Error) String

func (e *Error) String() string

type Form

type Form struct {
	Data FormData `json:"data"`
	// contains filtered or unexported fields
}

func (*Form) Bytes

func (f *Form) Bytes() []byte

func (*Form) Clone

func (f *Form) Clone() *Body

func (*Form) ContentLength

func (f *Form) ContentLength() int64

func (*Form) Merge

func (f *Form) Merge(data npncore.Data, logger *logrus.Logger) Config

func (*Form) MimeType

func (f *Form) MimeType() string

func (*Form) String

func (f *Form) String() string

type FormData

type FormData []*FormEntry

func (FormData) Clone

func (f FormData) Clone() FormData

func (FormData) String

func (f FormData) String() string

type FormEntry

type FormEntry struct {
	K string `json:"k"`
	V string `json:"v"`
}

func (*FormEntry) Clone

func (f *FormEntry) Clone() *FormEntry

func (*FormEntry) String

func (f *FormEntry) String() string

type HTML

type HTML struct {
	Content string `json:"content"`
}

func (*HTML) Bytes

func (h *HTML) Bytes() []byte

func (*HTML) Clone

func (h *HTML) Clone() *Body

func (*HTML) ContentLength

func (h *HTML) ContentLength() int64

func (*HTML) Merge

func (h *HTML) Merge(data npncore.Data, logger *logrus.Logger) Config

func (*HTML) MimeType

func (h *HTML) MimeType() string

func (*HTML) String

func (h *HTML) String() string

type Image

type Image struct {
	Type    string `json:"type"`
	Content string `json:"content"`
}

func (*Image) Bytes

func (r *Image) Bytes() []byte

func (*Image) Clone

func (r *Image) Clone() *Body

func (*Image) ContentLength

func (r *Image) ContentLength() int64

func (*Image) Merge

func (r *Image) Merge(data npncore.Data, logger *logrus.Logger) Config

func (*Image) MimeType

func (r *Image) MimeType() string

func (*Image) String

func (r *Image) String() string

type JSON

type JSON struct {
	Msg interface{} `json:"msg"`
	// contains filtered or unexported fields
}

func (*JSON) Bytes

func (j *JSON) Bytes() []byte

func (*JSON) Clone

func (j *JSON) Clone() *Body

func (*JSON) ContentLength

func (j *JSON) ContentLength() int64

func (*JSON) Merge

func (j *JSON) Merge(data npncore.Data, logger *logrus.Logger) Config

func (*JSON) MimeType

func (j *JSON) MimeType() string

func (*JSON) String

func (j *JSON) String() string

type Large

type Large struct {
	Filename    string `json:"filename"`
	ContentType string `json:"contentType"`
	Length      int64  `json:"length"`
}

func (*Large) Bytes

func (l *Large) Bytes() []byte

func (*Large) Clone

func (l *Large) Clone() *Body

func (*Large) ContentLength

func (l *Large) ContentLength() int64

func (*Large) Merge

func (l *Large) Merge(data npncore.Data, logger *logrus.Logger) Config

func (*Large) MimeType

func (l *Large) MimeType() string

func (*Large) String

func (l *Large) String() string

type Raw

type Raw struct {
	Type    string `json:"type"`
	Content string `json:"content"`
	Length  int64  `json:"length,omitempty"`
	Binary  bool   `json:"binary,omitempty"`
}

func (*Raw) Bytes

func (r *Raw) Bytes() []byte

func (*Raw) Clone

func (r *Raw) Clone() *Body

func (*Raw) ContentLength

func (r *Raw) ContentLength() int64

func (*Raw) Merge

func (r *Raw) Merge(data npncore.Data, logger *logrus.Logger) Config

func (*Raw) MimeType

func (r *Raw) MimeType() string

func (*Raw) String

func (r *Raw) String() string

type XML

type XML struct {
	Content string `json:"content"`
}

func (*XML) Bytes

func (h *XML) Bytes() []byte

func (*XML) Clone

func (h *XML) Clone() *Body

func (*XML) ContentLength

func (h *XML) ContentLength() int64

func (*XML) Merge

func (h *XML) Merge(data npncore.Data, logger *logrus.Logger) Config

func (*XML) MimeType

func (h *XML) MimeType() string

func (*XML) String

func (h *XML) String() string

Jump to

Keyboard shortcuts

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