Documentation ¶
Index ¶
- Constants
- type Data
- type Engine
- type Head
- type JSON
- type JSONP
- type Render
- func (r *Render) Data(ctx *fasthttp.RequestCtx, status int, v []byte) error
- func (r *Render) JSON(ctx *fasthttp.RequestCtx, status int, v interface{}) error
- func (r *Render) JSONP(ctx *fasthttp.RequestCtx, status int, callback string, v interface{}) error
- func (r *Render) Markdown(markdownBytes []byte) string
- func (r *Render) Render(ctx *fasthttp.RequestCtx, e Engine, data interface{}) error
- func (r *Render) Text(ctx *fasthttp.RequestCtx, status int, v string) error
- func (r *Render) XML(ctx *fasthttp.RequestCtx, status int, v interface{}) error
- type Text
- type XML
Constants ¶
const ( // ContentBinary header value for binary data. ContentBinary = "application/octet-stream" // ContentJSON header value for JSON data. ContentJSON = "application/json" // ContentJSONP header value for JSONP data. ContentJSONP = "application/javascript" // ContentLength header constant. ContentLength = "Content-Length" // ContentText header value for Text data. ContentText = "text/plain" // ContentType header constant. ContentType = "Content-Type" // ContentXML header value for XML data. ContentXML = "text/xml" )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Data ¶
type Data struct {
Head
}
Data built-in renderer.
func (Data) Render ¶
func (d Data) Render(ctx *fasthttp.RequestCtx, v interface{}) error
Render a data response.
func (Data) RenderGzip ¶
func (d Data) RenderGzip(ctx *fasthttp.RequestCtx, v interface{}) error
RenderGzip a data response using gzip compression.
type Engine ¶
type Engine interface { Render(*fasthttp.RequestCtx, interface{}) error //used only if config gzip is enabled RenderGzip(*fasthttp.RequestCtx, interface{}) error }
Engine is the generic interface for all responses.
type JSON ¶
JSON built-in renderer.
func (JSON) Render ¶
func (j JSON) Render(ctx *fasthttp.RequestCtx, v interface{}) error
Render a JSON response.
func (JSON) RenderGzip ¶
func (j JSON) RenderGzip(ctx *fasthttp.RequestCtx, v interface{}) error
RenderGzip a JSON response using gzip compression.
type JSONP ¶
JSONP built-in renderer.
func (JSONP) Render ¶
func (j JSONP) Render(ctx *fasthttp.RequestCtx, v interface{}) error
Render a JSONP response.
func (JSONP) RenderGzip ¶
func (j JSONP) RenderGzip(ctx *fasthttp.RequestCtx, v interface{}) error
RenderGzip a JSONP response using gzip compression.
type Render ¶
type Render struct { // Customize Secure with an Options struct. Config config.Rest CompiledCharset string }
Render is a service that provides functions for easily writing JSON, XML, binary data, and HTML templates out to a HTTP Response.
func (*Render) JSON ¶
func (r *Render) JSON(ctx *fasthttp.RequestCtx, status int, v interface{}) error
JSON marshals the given interface object and writes the JSON response.
func (*Render) Markdown ¶
Markdown parses and returns the converted html from a markdown []byte accepts two parameters first is the http status code second is the markdown string
Note that: Works different than the other rest's functions.
func (*Render) Render ¶
func (r *Render) Render(ctx *fasthttp.RequestCtx, e Engine, data interface{}) error
Render is the generic function called by XML, JSON, Data, HTML, and can be called by custom implementations.
type Text ¶
type Text struct {
Head
}
Text built-in renderer.
func (Text) Render ¶
func (t Text) Render(ctx *fasthttp.RequestCtx, v interface{}) error
Render a text response.
func (Text) RenderGzip ¶
func (t Text) RenderGzip(ctx *fasthttp.RequestCtx, v interface{}) error
RenderGzip a Text response using gzip compression.
type XML ¶
XML built-in renderer.
func (XML) Render ¶
func (x XML) Render(ctx *fasthttp.RequestCtx, v interface{}) error
Render an XML response.
func (XML) RenderGzip ¶
func (x XML) RenderGzip(ctx *fasthttp.RequestCtx, v interface{}) error
RenderGzip an XML response using gzip compression.