Documentation ¶
Overview ¶
Package request of the Tideland Go REST Server Library provides a simple way to handle cross-server requests in the Tideland REST ecosystem.
Index ¶
Constants ¶
View Source
const ( ErrNoServerDefined = iota + 1 ErrCannotPrepareRequest ErrHTTPRequestFailed ErrProcessingRequestContent ErrInvalidContent ErrAnalyzingResponse ErrDecodingResponse ErrInvalidContentType )
Variables ¶
This section is empty.
Functions ¶
func NewContext ¶
NewContext returns a new context that carries configured servers.
Types ¶
type Caller ¶
type Caller interface { // Get performs a GET request on the defined resource. Get(resource, resourceID string, params *Parameters) (Response, error) // Head performs a HEAD request on the defined resource. Head(resource, resourceID string, params *Parameters) (Response, error) // Put performs a PUT request on the defined resource. Put(resource, resourceID string, params *Parameters) (Response, error) // Post performs a POST request on the defined resource. Post(resource, resourceID string, params *Parameters) (Response, error) // Patch performs a PATCH request on the defined resource. Patch(resource, resourceID string, params *Parameters) (Response, error) // Delete performs a DELETE request on the defined resource. Delete(resource, resourceID string, params *Parameters) (Response, error) // Options performs a OPTIONS request on the defined resource. Options(resource, resourceID string, params *Parameters) (Response, error) }
Caller provides an interface to make calls to configured services.
type Parameters ¶
type Parameters struct { Version version.Version Token jwt.JWT ContentType string Content interface{} Accept string }
Parameters allows to pass parameters to a call.
type Response ¶
type Response interface { // StatusCode returns the HTTP status code of the response. StatusCode() int // Header returns the HTTP header of the response. Header() http.Header // HasContentType checks the content type regardless of charsets. HasContentType(contentType string) bool // Read decodes the content into the passed data depending // on the content type. Read(data interface{}) error // ReadFeedback tries to unmarshal the content of the // response into a rest package feedback. ReadFeedback() (rest.Feedback, bool) }
Response wraps all infos of a test response.
type Servers ¶
type Servers interface { // Add adds a domain server configuration. Add(domain string, url string, transport *http.Transport) // Caller retrieves a caller for a domain. Caller(domain string) (Caller, error) }
Servers maps IDs of domains to their server configurations. Multiple ones can be added per domain for spreading the load or provide higher availability.
func FromContext ¶
FromContext returns the servers configuration stored in ctx, if any.
Click to show internal directories.
Click to hide internal directories.