hateoas

package module
Version: v0.0.0-...-c91505a Latest Latest
Warning

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

Go to latest
Published: Apr 28, 2015 License: MIT Imports: 6 Imported by: 0

README

go-hateoas

A lightweight golang hateoas framework
(not stable - currently under development)

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Handle

func Handle(apiPath string, rh ResourceHandler) error

Types

type Error

type Error struct {
	Status           int    `json:"status"`
	Code             int    `json:"code"`
	Property         string `json:"property,omitempty"`
	Message          string `json:"message"`
	DeveloperMessage string `json:"developerMessage"`
	MoreInfo         string `json:"moreInfo,omitempty"`
}

This is a returned type Error type for REST hateoas

func (*Error) Error

func (e *Error) Error() string

type Page

type Page struct {
	Href     Url
	Offset   int
	Limit    int
	First    *Url
	Previous *Url
	Next     *Url
	Last     *Url
	Items    []hateoasResource

	TotalItems int
}

This is a returned type Page type for REST hateoas

type PageOpts

type PageOpts struct {
	Offset int
	Limit  int
}

PageOpts type for page options extracted from the GET parameters

type Resource

type Resource interface {
	GetId() string
}

Abstract interface for a REST resource

type ResourceHandler

type ResourceHandler interface {
	ResourceName() string

	GetOne(string) (Resource, *Error)
	GetAll(PageOpts) ([]Resource, *Error)
	Create(Resource) (string, *Error)
	Update(string, Resource) (Resource, *Error)
	Delete(string) *Error

	Count() (int, *Error)
}

Abstract interface for a REST resource handler

type Url

type Url string

URL type for representing HREF links

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
t or T : Toggle theme light dark auto
y or Y : Canonical URL