ginja

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

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

Go to latest
Published: Jun 30, 2015 License: Apache-2.0 Imports: 9 Imported by: 0

README

ginja

This is a super unstable jsonapi compliant api for gin.

Absolut heavy alpha stage, just sketching out ideas how to handle this with a interface oriented approach.

developing

Uses goconvey for testing and godep for dependency management.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Api

type Api struct {
	Config
	Store
}

func (*Api) Register

func (a *Api) Register(i interface{})

type Config

type Config struct {
	Namespace  string
	Version    string
	MountStats bool `json:"-"`
	StatsURL   string
	Debug      bool
}

func (*Config) ApplyDefaults

func (c *Config) ApplyDefaults()

type Document

type Document struct {
	Data   interface{}
	Meta   map[string]interface{}
	Errors []Error
	// contains filtered or unexported fields
}

func NewCollectionDocument

func NewCollectionDocument() Document

func NewDocument

func NewDocument() Document

func NewErrorDocument

func NewErrorDocument() Document

func (*Document) AddData

func (d *Document) AddData(data Resource)

func (*Document) AddError

func (d *Document) AddError(err error) *Document

func (*Document) AddMeta

func (d *Document) AddMeta(meta map[string]interface{}) *Document

func (Document) MarshalJSON

func (d Document) MarshalJSON() ([]byte, error)

type Error

type Error struct {
	Id      string `json:"id,omitempty"`
	Status  int    `json:"status,omitempty"`
	Code    string `json:"code,omitempty"`
	Title   string `json:"title,omitempty"`
	Details string `json:"detail,omitempty"`
}

func NewError

func NewError(err interface{}) Error

func (Error) Error

func (e Error) Error() string

type ErrorDocument

type ErrorDocument Document

type Fragment

type Fragment struct {
	Type       string      `json:"type"`
	Id         string      `json:"id"`
	Attributes interface{} `json:"attributes,omitempty"`
}

type GinApi

type GinApi struct {
	*gin.RouterGroup
	Api
}

func New

func New(server *gin.Engine, config Config, middleware ...gin.HandlerFunc) *GinApi

New returns a new ginja.Api struct

type Resource

type Resource interface {
	GetId() string
	Attributes() interface{}
	// contains filtered or unexported methods
}

type ResourceObject

type ResourceObject struct {
	Id     string
	Object interface{}
}

func (ResourceObject) Attributes

func (r ResourceObject) Attributes() interface{}

func (ResourceObject) GetId

func (r ResourceObject) GetId() string

type Store

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

func (*Store) NameFor

func (s *Store) NameFor(i interface{}) string

Directories

Path Synopsis
examples

Jump to

Keyboard shortcuts

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