jsonapi

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

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

Go to latest
Published: Nov 26, 2018 License: MIT Imports: 6 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Error

type Error struct {
	Error   string `json:"error"`
	Status  int    `json:"status"`
	Message string `json:"message"`
}

Error struct

type HTTPErrorCallback

type HTTPErrorCallback func(statusCode int, statusMessage, errorMessage string)

HTTPErrorCallback runs on a errored HTTP request

type InternalErrorCallback

type InternalErrorCallback func(error)

InternalErrorCallback runs on an internal error

type JSONAPI

type JSONAPI struct {
	BaseURL string
	Headers map[string]string
	// contains filtered or unexported fields
}

JSONAPI struct

func (*JSONAPI) Delete

func (jsonAPI *JSONAPI) Delete(url string, parameters url.Values,
	responseBody interface{}, onSuccess SuccessCallback, onHTTPError HTTPErrorCallback,
	onInternalError InternalErrorCallback) (response *http.Response, err error)

Delete request

func (*JSONAPI) Get

func (jsonAPI *JSONAPI) Get(url string, parameters url.Values,
	responseBody interface{}, onSuccess SuccessCallback, onHTTPError HTTPErrorCallback,
	onInternalError InternalErrorCallback) (response *http.Response, err error)

Get request

func (*JSONAPI) Post

func (jsonAPI *JSONAPI) Post(url string, parameters url.Values,
	requestBody interface{}, responseBody interface{}, onSuccess SuccessCallback,
	onHTTPError HTTPErrorCallback, onInternalError InternalErrorCallback) (response *http.Response, err error)

Post request

func (*JSONAPI) Put

func (jsonAPI *JSONAPI) Put(url string, parameters url.Values,
	requestBody interface{}, responseBody interface{}, onSuccess SuccessCallback,
	onHTTPError HTTPErrorCallback, onInternalError InternalErrorCallback) (response *http.Response, err error)

Put request

func (*JSONAPI) R

func (jsonAPI *JSONAPI) R() *Request

func (*JSONAPI) Use

func (jsonAPI *JSONAPI) Use(mw ...MiddlewareFunction)

type MiddlewareFunction

type MiddlewareFunction func(r *http.Request) error

type Request

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

func (*Request) Delete

func (r *Request) Delete(url string, parameters url.Values,
	responseBody interface{}, onSuccess SuccessCallback, onHTTPError HTTPErrorCallback,
	onInternalError InternalErrorCallback) (response *http.Response, err error)

Delete request

func (*Request) Get

func (r *Request) Get(url string, parameters url.Values,
	responseBody interface{}, onSuccess SuccessCallback, onHTTPError HTTPErrorCallback,
	onInternalError InternalErrorCallback) (response *http.Response, err error)

Get request

func (*Request) Post

func (r *Request) Post(url string, parameters url.Values,
	responseBody interface{}, requestBody interface{}, onSuccess SuccessCallback, onHTTPError HTTPErrorCallback,
	onInternalError InternalErrorCallback) (response *http.Response, err error)

Post request

func (*Request) Put

func (r *Request) Put(url string, parameters url.Values,
	responseBody interface{}, requestBody interface{}, onSuccess SuccessCallback, onHTTPError HTTPErrorCallback,
	onInternalError InternalErrorCallback) (response *http.Response, err error)

Put request

func (*Request) SetBody

func (r *Request) SetBody(v *bytes.Reader)

func (*Request) SetHeader

func (r *Request) SetHeader(key, value string) *Request

type SuccessCallback

type SuccessCallback func()

SuccessCallback runs on a successfull request and parse

Jump to

Keyboard shortcuts

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