rest

package module
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Nov 14, 2018 License: BSD-3-Clause Imports: 13 Imported by: 5

README

Tristan rest API

Allows accessing functions from the rest api.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var RestHttpClient = &http.Client{
	Transport: &http.Transport{
		Proxy:                 http.ProxyFromEnvironment,
		MaxIdleConns:          100,
		IdleConnTimeout:       90 * time.Second,
		TLSHandshakeTimeout:   10 * time.Second,
		ExpectContinueTimeout: 1 * time.Second,
	},
	Timeout: 120 * time.Second,
}
View Source
var (
	SystemProxy = &httputil.ReverseProxy{
		Director:  systemProxyDirector,
		Transport: RestHttpClient.Transport,
	}
)

Functions

func Apply

func Apply(ctx context.Context, req, method string, param map[string]interface{}, target interface{}) error

func RedirectError

func RedirectError(u *url.URL) error

func RedirectErrorCode

func RedirectErrorCode(u *url.URL, code int) error

code can be one of http.StatusMovedPermanently or http.StatusFound or any 3xx http status code

func SendRedirect

func SendRedirect(w http.ResponseWriter, url string, code int)

Types

type RestParam

type RestParam map[string]interface{}

type RestResponse

type RestResponse struct {
	Result string          `json:"result"` // "success" or "error" (or "redirect")
	Data   json.RawMessage `json:"data"`
	Error  string          `json:"error"`

	Paging interface{} `json:"paging"`
	Job    interface{} `json:"job"`
	Time   interface{} `json:"time"`
	Access interface{} `json:"access"`

	RedirectUrl  string `json:"redirect_url"`
	RedirectCode int    `json:"redirect_code"`
}

func Do

func Do(ctx context.Context, req, method string, param map[string]interface{}) (*RestResponse, error)

func (*RestResponse) ReadValue

func (r *RestResponse) ReadValue(ctx context.Context) (interface{}, error)

Jump to

Keyboard shortcuts

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