resource

package
v0.0.0-...-1bce007 Latest Latest
Warning

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

Go to latest
Published: Nov 18, 2020 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func HTTPErrorPtr

func HTTPErrorPtr(err error, msg string, status int) *api2go.HTTPError

HTTPErrorPtr makes an *api2go.HTTPError by the given function arguments, where err is an error that had occurred, msg is a text that you might want to show to the visitor, status is a http status you want to return along with the error message

func HTTPErrorPtrWithStatus

func HTTPErrorPtrWithStatus(err error, msg string) *api2go.HTTPError

HTTPErrorPtrWithStatus is a shortcut to HTTPErrorPtr that uses StatusByError for the given error to define the http status

func StatusByError

func StatusByError(err error) int

StatusByError gives a http error for a particular go error

Types

type LinkResource

type LinkResource struct {
	LinkStorage linkstorage.Storage
	// contains filtered or unexported fields
}

LinkResource for api2go routes

func NewLinkResource

func NewLinkResource(linkStorage linkstorage.Storage) *LinkResource

NewLinkResource creates a new LinkResource instance for a given link storage

func (*LinkResource) Create

func (c *LinkResource) Create(obj interface{}, _ api2go.Request) (api2go.Responder, error)

Create a new link @Summary Create a new link @Description add by link json @Tags links @Accept json-api @Produce json-api @Param link body jsonapi.CreateLink true "Add link" @Success 201 {object} jsonapi.CreatedLink @Router /links [post]

func (*LinkResource) Delete

func (c *LinkResource) Delete(id string, _ api2go.Request) (api2go.Responder, error)

Delete a link :( @Summary Delete a link @Description Delete by link ID @Tags links @Accept json-api @Produce json-api @Param id path int true "Link ID" @Success 204 @Router /links/{id} [delete]

func (*LinkResource) FindAll

func (c *LinkResource) FindAll(r api2go.Request) (api2go.Responder, error)

FindAll links @Summary List links @Description get links @Tags links @Accept json-api @Produce json-api @Param page[number] query int false "Page number" default(1) @Param page[size] query int false "Page size" default(10) maximum(1000) @Success 200 {object} jsonapi.Links @Router /links [get]

func (*LinkResource) FindOne

func (c *LinkResource) FindOne(ID string, _ api2go.Request) (api2go.Responder, error)

FindOne link @Summary Get a link @Description get link by ID @Tags links @Accept json-api @Produce json-api @Param id path string true "Link ID" @Success 200 {object} jsonapi.Link @Router /links/{id} [get]

func (*LinkResource) Update

func (c *LinkResource) Update(obj interface{}, _ api2go.Request) (api2go.Responder, error)

Update a link @Summary Update a link @Description Update by link json @Tags links @Accept json-api @Produce json-api @Param id path int true "Link ID" @Param account body jsonapi.CreateLink true "Update link" @Success 200 {object} jsonapi.CreatedLink @Router /links/{id} [patch]

type Page

type Page struct {
	Number int
	Size   int
}

Page holds page number and page size used in pagination

type Response

type Response struct {
	Res  interface{}
	Code int
}

The Response struct implements api2go.Responder

func (Response) Metadata

func (r Response) Metadata() map[string]interface{}

Metadata returns additional meta data

func (Response) Result

func (r Response) Result() interface{}

Result returns the actual payload

func (Response) StatusCode

func (r Response) StatusCode() int

StatusCode sets the return status code

Jump to

Keyboard shortcuts

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