restapi

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Aug 11, 2020 License: MPL-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	Host           string
	ServiceAccount string
	Audience       string
	// contains filtered or unexported fields
}

Client represents a client for interaction with a GCP REST API

func (*Client) Do

func (c *Client) Do(baseURL string, req *Request) (int, []byte, error)

Do sends the API Request, parses the response as JSON, and returns the HTTP status code as int, the "result" value as byte

type Request

type Request struct {
	Method string      `json:"method"`
	Params interface{} `json:"params"`
}

Request represents a request to a REST API

func (*Request) BuildHTTPReq

func (r *Request) BuildHTTPReq(host string, serviceAccount string, audience string, baseURL string) (*http.Request, error)

BuildHTTPReq builds an HTTP request to carry out the REST request

type ResponseError

type ResponseError struct {
	Code    int    `json:"code"`
	Message string `json:"message"`
	Name    string `json:"name"`
}

ResponseError represents an Error to a REST API call

func (*ResponseError) Error

func (e *ResponseError) Error() string

Jump to

Keyboard shortcuts

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