render

package
v0.0.0-...-27684a5 Latest Latest
Warning

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

Go to latest
Published: Nov 30, 2023 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Data

type Data struct {
	ContentType string
	Data        []byte
}

Data contains ContentType and bytes data.

func (Data) Render

func (r Data) Render(w *fasthttp.RequestCtx) (err error)

Render (Data) writes data with custom ContentType.

func (Data) WriteContentType

func (r Data) WriteContentType(w *fasthttp.RequestCtx)

WriteContentType (Data) writes custom ContentType.

type JSON

type JSON struct {
	Data any
}

func (JSON) Render

func (r JSON) Render(w *fasthttp.RequestCtx) error

Render (JSON) writes data with custom ContentType.

func (JSON) WriteContentType

func (r JSON) WriteContentType(w *fasthttp.RequestCtx)

WriteContentType (JSON) writes JSON ContentType.

type Reader

type Reader struct {
	ContentType   string
	ContentLength int
	Reader        io.Reader
	Headers       map[string]string
}

Reader contains the IO reader and its length, and custom ContentType and other headers.

func (Reader) Render

func (r Reader) Render(w *fasthttp.RequestCtx) (err error)

Render (Reader) writes data with custom ContentType and headers.

func (Reader) WriteContentType

func (r Reader) WriteContentType(w *fasthttp.RequestCtx)

WriteContentType (Reader) writes custom ContentType.

type Render

type Render interface {
	// Render writes data with custom ContentType.
	Render(w *fasthttp.RequestCtx) error
	// WriteContentType writes custom ContentType.
	WriteContentType(w *fasthttp.RequestCtx)
}

Render interface is to be implemented by JSON, XML, HTML, YAML and so on.

type Text

type Text struct {
	Format string
	Data   []any
}

Text contains the given interface object slice and its format.

func (Text) Render

func (r Text) Render(w *fasthttp.RequestCtx) error

Render (Text) writes data with custom ContentType.

func (Text) WriteContentType

func (r Text) WriteContentType(w *fasthttp.RequestCtx)

WriteContentType (Text) writes Plain ContentType.

Jump to

Keyboard shortcuts

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