gin: github.com/gin-gonic/gin/render Index | Files

package render

import "github.com/gin-gonic/gin/render"

Index

Package Files

data.go html.go json.go json_17.go msgpack.go protobuf.go reader.go redirect.go render.go text.go xml.go yaml.go

func WriteJSON Uses

func WriteJSON(w http.ResponseWriter, obj interface{}) error

WriteJSON marshals the given interface object and writes it with custom ContentType.

func WriteMsgPack Uses

func WriteMsgPack(w http.ResponseWriter, obj interface{}) error

WriteMsgPack writes MsgPack ContentType and encodes the given interface object.

func WriteString Uses

func WriteString(w http.ResponseWriter, format string, data []interface{})

WriteString writes data according to its format and write custom ContentType.

type AsciiJSON Uses

type AsciiJSON struct {
    Data interface{}
}

AsciiJSON contains the given interface object.

func (AsciiJSON) Render Uses

func (r AsciiJSON) Render(w http.ResponseWriter) (err error)

Render (AsciiJSON) marshals the given interface object and writes it with custom ContentType.

func (AsciiJSON) WriteContentType Uses

func (r AsciiJSON) WriteContentType(w http.ResponseWriter)

WriteContentType (AsciiJSON) writes JSON ContentType.

type Data Uses

type Data struct {
    ContentType string
    Data        []byte
}

Data contains ContentType and bytes data.

func (Data) Render Uses

func (r Data) Render(w http.ResponseWriter) (err error)

Render (Data) writes data with custom ContentType.

func (Data) WriteContentType Uses

func (r Data) WriteContentType(w http.ResponseWriter)

WriteContentType (Data) writes custom ContentType.

type Delims Uses

type Delims struct {
    // Left delimiter, defaults to {{.
    Left string
    // Right delimiter, defaults to }}.
    Right string
}

Delims represents a set of Left and Right delimiters for HTML template rendering.

type HTML Uses

type HTML struct {
    Template *template.Template
    Name     string
    Data     interface{}
}

HTML contains template reference and its name with given interface object.

func (HTML) Render Uses

func (r HTML) Render(w http.ResponseWriter) error

Render (HTML) executes template and writes its result with custom ContentType for response.

func (HTML) WriteContentType Uses

func (r HTML) WriteContentType(w http.ResponseWriter)

WriteContentType (HTML) writes HTML ContentType.

type HTMLDebug Uses

type HTMLDebug struct {
    Files   []string
    Glob    string
    Delims  Delims
    FuncMap template.FuncMap
}

HTMLDebug contains template delims and pattern and function with file list.

func (HTMLDebug) Instance Uses

func (r HTMLDebug) Instance(name string, data interface{}) Render

Instance (HTMLDebug) returns an HTML instance which it realizes Render interface.

type HTMLProduction Uses

type HTMLProduction struct {
    Template *template.Template
    Delims   Delims
}

HTMLProduction contains template reference and its delims.

func (HTMLProduction) Instance Uses

func (r HTMLProduction) Instance(name string, data interface{}) Render

Instance (HTMLProduction) returns an HTML instance which it realizes Render interface.

type HTMLRender Uses

type HTMLRender interface {
    // Instance returns an HTML instance.
    Instance(string, interface{}) Render
}

HTMLRender interface is to be implemented by HTMLProduction and HTMLDebug.

type IndentedJSON Uses

type IndentedJSON struct {
    Data interface{}
}

IndentedJSON contains the given interface object.

func (IndentedJSON) Render Uses

func (r IndentedJSON) Render(w http.ResponseWriter) error

Render (IndentedJSON) marshals the given interface object and writes it with custom ContentType.

func (IndentedJSON) WriteContentType Uses

func (r IndentedJSON) WriteContentType(w http.ResponseWriter)

WriteContentType (IndentedJSON) writes JSON ContentType.

type JSON Uses

type JSON struct {
    Data interface{}
}

JSON contains the given interface object.

func (JSON) Render Uses

func (r JSON) Render(w http.ResponseWriter) (err error)

Render (JSON) writes data with custom ContentType.

func (JSON) WriteContentType Uses

func (r JSON) WriteContentType(w http.ResponseWriter)

WriteContentType (JSON) writes JSON ContentType.

type JsonpJSON Uses

type JsonpJSON struct {
    Callback string
    Data     interface{}
}

JsonpJSON contains the given interface object its callback.

func (JsonpJSON) Render Uses

func (r JsonpJSON) Render(w http.ResponseWriter) (err error)

Render (JsonpJSON) marshals the given interface object and writes it and its callback with custom ContentType.

func (JsonpJSON) WriteContentType Uses

func (r JsonpJSON) WriteContentType(w http.ResponseWriter)

WriteContentType (JsonpJSON) writes Javascript ContentType.

type MsgPack Uses

type MsgPack struct {
    Data interface{}
}

MsgPack contains the given interface object.

func (MsgPack) Render Uses

func (r MsgPack) Render(w http.ResponseWriter) error

Render (MsgPack) encodes the given interface object and writes data with custom ContentType.

func (MsgPack) WriteContentType Uses

func (r MsgPack) WriteContentType(w http.ResponseWriter)

WriteContentType (MsgPack) writes MsgPack ContentType.

type ProtoBuf Uses

type ProtoBuf struct {
    Data interface{}
}

ProtoBuf contains the given interface object.

func (ProtoBuf) Render Uses

func (r ProtoBuf) Render(w http.ResponseWriter) error

Render (ProtoBuf) marshals the given interface object and writes data with custom ContentType.

func (ProtoBuf) WriteContentType Uses

func (r ProtoBuf) WriteContentType(w http.ResponseWriter)

WriteContentType (ProtoBuf) writes ProtoBuf ContentType.

type PureJSON Uses

type PureJSON struct {
    Data interface{}
}

PureJSON contains the given interface object.

func (PureJSON) Render Uses

func (r PureJSON) Render(w http.ResponseWriter) error

Render (PureJSON) writes custom ContentType and encodes the given interface object.

func (PureJSON) WriteContentType Uses

func (r PureJSON) WriteContentType(w http.ResponseWriter)

WriteContentType (PureJSON) writes custom ContentType.

type Reader Uses

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

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

func (Reader) Render Uses

func (r Reader) Render(w http.ResponseWriter) (err error)

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

func (Reader) WriteContentType Uses

func (r Reader) WriteContentType(w http.ResponseWriter)

WriteContentType (Reader) writes custom ContentType.

type Redirect Uses

type Redirect struct {
    Code     int
    Request  *http.Request
    Location string
}

Redirect contains the http request reference and redirects status code and location.

func (Redirect) Render Uses

func (r Redirect) Render(w http.ResponseWriter) error

Render (Redirect) redirects the http request to new location and writes redirect response.

func (Redirect) WriteContentType Uses

func (r Redirect) WriteContentType(http.ResponseWriter)

WriteContentType (Redirect) don't write any ContentType.

type Render Uses

type Render interface {
    // Render writes data with custom ContentType.
    Render(http.ResponseWriter) error
    // WriteContentType writes custom ContentType.
    WriteContentType(w http.ResponseWriter)
}

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

type SecureJSON Uses

type SecureJSON struct {
    Prefix string
    Data   interface{}
}

SecureJSON contains the given interface object and its prefix.

func (SecureJSON) Render Uses

func (r SecureJSON) Render(w http.ResponseWriter) error

Render (SecureJSON) marshals the given interface object and writes it with custom ContentType.

func (SecureJSON) WriteContentType Uses

func (r SecureJSON) WriteContentType(w http.ResponseWriter)

WriteContentType (SecureJSON) writes JSON ContentType.

type SecureJSONPrefix Uses

type SecureJSONPrefix string

SecureJSONPrefix is a string which represents SecureJSON prefix.

type String Uses

type String struct {
    Format string
    Data   []interface{}
}

String contains the given interface object slice and its format.

func (String) Render Uses

func (r String) Render(w http.ResponseWriter) error

Render (String) writes data with custom ContentType.

func (String) WriteContentType Uses

func (r String) WriteContentType(w http.ResponseWriter)

WriteContentType (String) writes Plain ContentType.

type XML Uses

type XML struct {
    Data interface{}
}

XML contains the given interface object.

func (XML) Render Uses

func (r XML) Render(w http.ResponseWriter) error

Render (XML) encodes the given interface object and writes data with custom ContentType.

func (XML) WriteContentType Uses

func (r XML) WriteContentType(w http.ResponseWriter)

WriteContentType (XML) writes XML ContentType for response.

type YAML Uses

type YAML struct {
    Data interface{}
}

YAML contains the given interface object.

func (YAML) Render Uses

func (r YAML) Render(w http.ResponseWriter) error

Render (YAML) marshals the given interface object and writes data with custom ContentType.

func (YAML) WriteContentType Uses

func (r YAML) WriteContentType(w http.ResponseWriter)

WriteContentType (YAML) writes YAML ContentType for response.

Package render imports 11 packages (graph) and is imported by 212 packages. Updated 2018-10-12. Refresh now. Tools for package owners.