json

package module
v0.0.0-...-a95e4f9 Latest Latest
Warning

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

Go to latest
Published: Dec 27, 2018 License: MIT Imports: 8 Imported by: 0

README

Gin Binding and Render json implement

Sample usage

package main

import (
	"github.com/alimy/gin"
	_ "github.com/alimy/gin/module/json"
)

func main() {
	// TODO
}

Documentation

Index

Constants

This section is empty.

Variables

View Source
var EnableDecoderUseNumber = false

EnableDecoderUseNumber is used to call the UseNumber method on the JSON Decoder instance. UseNumber causes the Decoder to unmarshal a number into an interface{} as a Number instead of as a float64.

Functions

func EnableJsonDecoderUseNumber

func EnableJsonDecoderUseNumber()

EnableJsonDecoderUseNumber sets true for binding.EnableDecoderUseNumberto to call the UseNumber method on the JSON Decoder instance.

func WriteJSON

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

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

Types

type AsciiJSONRender

type AsciiJSONRender struct {
	Data interface{}
}

AsciiJSON contains the given interface object.

func (*AsciiJSONRender) Render

func (r *AsciiJSONRender) Render(w http.ResponseWriter) (err error)

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

func (*AsciiJSONRender) Reset

func (r *AsciiJSONRender) Reset()

Reset clean data and opts

func (*AsciiJSONRender) Setup

func (r *AsciiJSONRender) Setup(data interface{}, opts ...interface{})

Setup set data and opts

func (*AsciiJSONRender) WriteContentType

func (*AsciiJSONRender) WriteContentType(w http.ResponseWriter)

WriteContentType (AsciiJSON) writes JSON ContentType.

type AsciiJSONRenderFactory

type AsciiJSONRenderFactory struct{}

AsciiJSONRenderFactory contains the given interface object.

func (AsciiJSONRenderFactory) Instance

Instance a new Render instance

type IndentedJSONRender

type IndentedJSONRender struct {
	Data interface{}
}

IndentedJSON contains the given interface object.

func (*IndentedJSONRender) Render

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

func (*IndentedJSONRender) Reset

func (r *IndentedJSONRender) Reset()

Reset clean data and opts

func (*IndentedJSONRender) Setup

func (r *IndentedJSONRender) Setup(data interface{}, opts ...interface{})

Setup set data and opts

func (*IndentedJSONRender) WriteContentType

func (*IndentedJSONRender) WriteContentType(w http.ResponseWriter)

WriteContentType (IndentedJSON) writes JSON ContentType.

type IndentedJSONRenderFactory

type IndentedJSONRenderFactory struct{}

IndentedJSONRenderFactory contains the given interface object.

func (IndentedJSONRenderFactory) Instance

Instance a new Render instance

type JSONRender

type JSONRender struct {
	Data interface{}
}

JSON contains the given interface object.

func (*JSONRender) Render

func (r *JSONRender) Render(w http.ResponseWriter) (err error)

Render (JSON) writes data with custom ContentType.

func (*JSONRender) Reset

func (r *JSONRender) Reset()

Reset clean data and opts

func (*JSONRender) Setup

func (r *JSONRender) Setup(data interface{}, opts ...interface{})

Setup set data and opts

func (*JSONRender) WriteContentType

func (r *JSONRender) WriteContentType(w http.ResponseWriter)

WriteContentType (JSON) writes JSON ContentType.

type JSONRenderFactory

type JSONRenderFactory struct{}

JSONRenderFactory contains the given interface object.

func (JSONRenderFactory) Instance

Instance a new Render instance

type JsonpJSONRender

type JsonpJSONRender struct {
	Callback string
	Data     interface{}
}

JsonpJSON contains the given interface object its callback.

func (*JsonpJSONRender) Render

func (r *JsonpJSONRender) Render(w http.ResponseWriter) (err error)

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

func (*JsonpJSONRender) Reset

func (r *JsonpJSONRender) Reset()

Reset clean data and opts

func (*JsonpJSONRender) Setup

func (r *JsonpJSONRender) Setup(data interface{}, opts ...interface{})

Setup set data and opts

func (*JsonpJSONRender) WriteContentType

func (*JsonpJSONRender) WriteContentType(w http.ResponseWriter)

WriteContentType (JsonpJSON) writes Javascript ContentType.

type JsonpJSONRenderFactory

type JsonpJSONRenderFactory struct{}

JsonpJSONRenderFactory contains the given interface object.

func (JsonpJSONRenderFactory) Instance

Instance a new Render instance

type PureJSONRender

type PureJSONRender struct {
	Data interface{}
}

PureJSON contains the given interface object.

func (*PureJSONRender) Render

func (r *PureJSONRender) Render(w http.ResponseWriter) error

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

func (*PureJSONRender) Reset

func (r *PureJSONRender) Reset()

Reset clean data and opts

func (*PureJSONRender) Setup

func (r *PureJSONRender) Setup(data interface{}, opts ...interface{})

Setup set data and opts

func (*PureJSONRender) WriteContentType

func (*PureJSONRender) WriteContentType(w http.ResponseWriter)

WriteContentType (PureJSON) writes custom ContentType.

type PureJsonRenderFactory

type PureJsonRenderFactory struct{}

func (PureJsonRenderFactory) Instance

Instance a new Render instance

type SecureJSONPrefix

type SecureJSONPrefix string

SecureJSONPrefix is a string which represents SecureJSON prefix.

type SecureJSONRender

type SecureJSONRender struct {
	Prefix string
	Data   interface{}
}

SecureJSON contains the given interface object and its prefix.

func (*SecureJSONRender) Render

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

func (*SecureJSONRender) Reset

func (r *SecureJSONRender) Reset()

Reset clean data and opts

func (*SecureJSONRender) Setup

func (r *SecureJSONRender) Setup(data interface{}, opts ...interface{})

Setup set data and opts

func (*SecureJSONRender) WriteContentType

func (*SecureJSONRender) WriteContentType(w http.ResponseWriter)

WriteContentType (SecureJSON) writes JSON ContentType.

type SecureJSONRenderFactory

type SecureJSONRenderFactory struct{}

SecureJSONRenderFactory contains the given interface object.

func (SecureJSONRenderFactory) Instance

Instance a new Render instance

Directories

Path Synopsis
internal

Jump to

Keyboard shortcuts

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