api

package
v0.0.0-...-bf0f985 Latest Latest
Warning

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

Go to latest
Published: Nov 15, 2020 License: GPL-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type API

type API struct{}

API is the generic "API" model

func (*API) Abort

func (api *API) Abort(rw http.ResponseWriter, statusCode int)

Abort just return the status code

func (*API) AddNonJSONResource

func (api *API) AddNonJSONResource(db *gorm.DB, resource NonJSONResource, path string)

AddNonJSONResource will add a non json Handler

func (*API) AddResource

func (api *API) AddResource(db *gorm.DB, resource Resource, path string)

AddResource add path to the http Handler

func (*API) Init

func (api *API) Init(db *gorm.DB)

Init will create the routes

func (*API) Start

func (api *API) Start(inetaddr string, port int)

Start starts the listener

type NonJSONData

type NonJSONData interface {
	GetContentType() string
	GetContentLength() string
	GetContent() []byte
}

NonJSONData represent any content that is not JSon, mostly images

type NonJSONResource

type NonJSONResource interface {
	Get(db *gorm.DB, values url.Values, id int) (int, interface{})
	Post(db *gorm.DB, values url.Values, request *http.Request, id int, adj string) (int, interface{})
	Put(db *gorm.DB, values url.Values, body io.ReadCloser) (int, interface{})
	Delete(db *gorm.DB, values url.Values, id int) (int, interface{})
}

NonJSONResource hold the files images and other objects

type Resource

type Resource interface {
	Get(db *gorm.DB, values url.Values, id int) (int, interface{})
	Post(db *gorm.DB, values url.Values, request *http.Request, id int, adj string) (int, interface{})
	Put(db *gorm.DB, values url.Values, body io.ReadCloser) (int, interface{})
	Delete(db *gorm.DB, values url.Values, id int) (int, interface{})
}

Resource will define the generic API resource methods

Jump to

Keyboard shortcuts

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