entry

package
v0.0.0-...-b1b0a22 Latest Latest
Warning

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

Go to latest
Published: Feb 4, 2016 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Bucket = "entries"
	Type   = "entry"
)

Bucket is the name of the bucket storing all the entries

Variables

This section is empty.

Functions

func Delete

func Delete(c *gin.Context)

Delete deletes a resource

func Get

func Get(c *gin.Context)

Get is the handler to GET an existing entry

func List

func List(c *gin.Context)

List lists the entries

func Patch

func Patch(c *gin.Context)

Patch is used to update a resource.

func Post

func Post(c *gin.Context)

Post is the handler to POST a new Entry

Types

type Data

type Data struct {
	Type       string `json:"type,omitempty"`
	Attributes *Entry `json:"attributes,omitempty"`
	Links      *Links `json:"links,omitempty"`
}

Data contains the Type of the request and the Attributes

type Entry

type Entry struct {
	ID       int    `json:"id"`
	Title    string `json:"title"`
	Markdown string `json:"markdown"`
}

Entry is the main struct

func All

func All() ([]Entry, error)

All returns all the entries

func (*Entry) Decode

func (e *Entry) Decode(data []byte) error

Decode loads an Entry from json

func (Entry) Delete

func (e Entry) Delete() error

Delete deletes an Entry from the database.

func (Entry) Encode

func (e Entry) Encode() ([]byte, error)

Encode dumps an Entry to json.

func (*Entry) Get

func (e *Entry) Get(key string) error

Get retrieves an Entry from the database.

func (*Entry) Save

func (e *Entry) Save() error

Save saves an Entry in the database.

func (Entry) Validate

func (e Entry) Validate() hateoas.Errors

Validate validates that all the required files are not empty.

type Links map[string]string

Links represent a list of links

type MultiWrapper

type MultiWrapper struct {
	Data   *[]Data         `json:"data,omitempty"`
	Errors *hateoas.Errors `json:"errors,omitempty"`
}

MultiWrapper is a wrapper that can accept multiple Data

type Wrapper

type Wrapper struct {
	Data   *Data           `json:"data,omitempty"`
	Errors *hateoas.Errors `json:"errors,omitempty"`
}

Wrapper is the HATEOAS wrapper

Jump to

Keyboard shortcuts

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