rc

package module
v0.0.7 Latest Latest
Warning

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

Go to latest
Published: Nov 28, 2018 License: BSD-3-Clause Imports: 7 Imported by: 0

README

rc

rc standands for "REST client". It is a golang package implementing a simple wrapper around Go's standard http/https packages targetting simple interactions with REST API such as https://orcid.org. It was created to unify the REST interaction across multiple harvesting tools developed at Caltech Library in the Go lanuage.

apiexplorer

apiexplorer is just a proof of concept command line program to demonstrate using rc package in Go programs.

Documentation

Index

Constants

View Source
const (
	Version = `v0.0.1`

	LicenseText = `` /* 1530-byte string literal not displayed */

)
View Source
const (
	AuthNone = iota
	BasicAuth
	OAuth
	Shibboleth
)

FIXME: Need to handle Basic auth, OAuth and Shibboleth

Variables

This section is empty.

Functions

This section is empty.

Types

type RestAPI

type RestAPI struct {

	// Timeout is the client time out period, default is 10 seconds
	Timeout time.Duration
	// contains filtered or unexported fields
}

func New

func New(apiURL string, authType int, clientID, clientSecret string) (*RestAPI, error)

New creates a new Rest Client RestAPI instance If clientID and clientSecret and empty and authType

func (*RestAPI) AddHeader

func (api *RestAPI) AddHeader(ky, value string)

AddHeader sets the header strings to send with the request

func (*RestAPI) Login

func (api *RestAPI) Login() error

func (*RestAPI) Request

func (api *RestAPI) Request(method, docPath string, payload map[string]string) ([]byte, error)

Request contacts the Rest API and returns the full read response body, and error payload is the used to build the URL Query object (e.g. ?key=value&key1=value...)

Directories

Path Synopsis
cmd
apiexplorer
apiexplorer is a demo program showing how to use and restclient package
apiexplorer is a demo program showing how to use and restclient package

Jump to

Keyboard shortcuts

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