iotmaker_server_json

package module
v0.0.0-...-6ba7046 Latest Latest
Warning

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

Go to latest
Published: Jul 27, 2019 License: Apache-2.0 Imports: 9 Imported by: 1

README

iotmaker.server

Documentation

Index

Examples

Constants

View Source
const KCacheDir string = "./cache"

Variables

This section is empty.

Functions

This section is empty.

Types

type MetaJSonOut

type MetaJSonOut struct {
	Cache      string   `json:"Cache,omitempty"`
	Limit      int64    `json:"Limit,omitempty"`
	Next       string   `json:"Next,omitempty"`
	Offset     int64    `json:"Offset"`
	Previous   string   `json:"Previous,omitempty"`
	TotalCount int      `json:"TotalCount,omitempty"`
	Success    bool     `json:"Success"`
	Error      []string `json:"Error,omitempty"`
}

pt-br: monta a parte de meta-data do restful en: mount a mate-data from a restful data out

func (*MetaJSonOut) AddError

func (el *MetaJSonOut) AddError(value string)

type Out

type Out struct {
	// contains filtered or unexported fields
}

func NewJSonOut

func NewJSonOut() Out

pt-br: retorna um novo struct JSonOut para restful en: return a new JSonOut struct for restful

func (*Out) Byte

func (el *Out) Byte() []byte

func (*Out) GetMachineName

func (el *Out) GetMachineName() string

func (*Out) GetRandString

func (el *Out) GetRandString(l int) string

func (*Out) GetTime

func (el *Out) GetTime() string

func (*Out) LoadCache

func (el *Out) LoadCache(id string) error

func (*Out) MakeId

func (el *Out) MakeId() string

func (*Out) SaveCache

func (el *Out) SaveCache() error
Example
out := NewJSonOut()
out.Id = "0000-0000-0000-0000"
out.Meta.Success = true
out.Meta.Limit = 30
out.Meta.Offset = 0
out.Meta.Next = "next.link"
out.Meta.Previous = "previous.link"
out.Objects = []string{"a", "b", "c"}

err := out.SaveCache()
if err != nil {
	panic(err)
}

id := out.Id

out = NewJSonOut()
err = out.LoadCache(id)
if err != nil {
	panic(err)
}

fmt.Printf("%v\n", out)
Output:

{{{ 30 next.link 0 previous.link 0 true []} [a b c]} 0000-0000-0000-0000}

Jump to

Keyboard shortcuts

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