rest

package
v0.0.0-...-b77c216 Latest Latest
Warning

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

Go to latest
Published: Aug 14, 2019 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ClientConfig

type ClientConfig struct {
	BaseURL   *url.URL
	SessionID SessionID
}

ClientConfig encapsulate the data needed to configure the HTTPClient

func NewConfig

func NewConfig(baseURL *url.URL, sessionID SessionID) *ClientConfig

NewConfig ...

type HTTPClient

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

HTTPClient provides a implementation of the Client interface

func NewHTTPClient

func NewHTTPClient(httpClient *http.Client, baseURL *url.URL, sessionID string) (*HTTPClient, error)

func (*HTTPClient) CreateRequest

func (client *HTTPClient) CreateRequest(method, path string, body []byte) (*http.Request, error)

CreateRequest builds a new request from the given parameters

func (*HTTPClient) Delete

func (client *HTTPClient) Delete(path string) (int, error)

Delete perform HTTP DELETE on path

func (*HTTPClient) Do

func (client *HTTPClient) Do(req *http.Request) (*http.Response, error)

Do executes the given request

func (*HTTPClient) Get

func (client *HTTPClient) Get(path string) (int, []byte, error)

Get create an HTTP GET to path and unmarshal the response body to data

func (*HTTPClient) Post

func (client *HTTPClient) Post(path string, jsonBody []byte) (int, []byte, error)

Post create an HTTP POST to path and put the body in the data

type Queries

type Queries []Query

func NewQueries

func NewQueries() Queries

func (Queries) Add

func (q Queries) Add(key, value string) Queries

type Query

type Query struct {
	Key   string
	Value string
}

Query ...

func NewQuery

func NewQuery(key, value string) Query

NewQuery ...

type Reference

type Reference struct {
	ID string `json:"id"`
}

Reference represents an ID to another REST resource

type SessionID

type SessionID string

SessionID represents a session ID. For proper validation use NewSession() func to initialize sessionID's.

func NewSession

func NewSession(session string) (SessionID, error)

NewSession validates and initializes a new session ID from a string.

func (SessionID) Value

func (s SessionID) Value() string

Value returns the string representation of the session ID

Jump to

Keyboard shortcuts

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